Solved How to clear Powershell command history?


elevenmax

Member
Local time
7:37 AM
Posts
18
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

System One

  • 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

System One

  • 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

System One

  • OS
    Windows 11

Latest Support Threads

Back
Top Bottom