Solved How to clear Powershell command history?


elevenmax

Active member
Local time
7:16 AM
Posts
26
OS
Windows 11
I have sensitive information from one of the commands in history and running Clear-History did not work on Powershell 7.
 

My Computer My Computer

At a glance

Windows 11AMD Ryzen 6800HDDR5 2X16GBAMD Radeon 600M
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
ASUS
CPU
AMD Ryzen 6800H
Motherboard
ASUS PN53
Memory
DDR5 2X16GB
Graphics Card(s)
AMD Radeon 600M
Sound Card
ON BOARD
Monitor(s) Displays
LG 27"
Read this thread, use the PS script provided in the response.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
I have make a function for this

Code:
function ch {
    # Clear history
    $path = (Get-PSReadlineOption).HistorySavePath
    Clear-Content $path
    Write-Host "History has been deleted"
    Invoke-Command { & "pwsh.exe" -nolog } -NoNewScope
}
 

My Computer My Computer

At a glance

Windows 11
OS
Windows 11

Latest Support Threads

Back
Top Bottom