shell.sogo.tw

一行安裝 script 目錄 v0824.2250

💡 清掉 PowerShell command history

一行清掉三層 history: 目前 session (Get-History) + PSReadLine 記憶體 (up 鍵回顧) + 磁碟上的持久 history 檔. pwsh 7 與 Windows PowerShell 5.1 都適用 (檔案路徑用 Get-PSReadLineOption 動態解析).

Clear-History; [Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory(); Remove-Item (Get-PSReadLineOption).HistorySavePath -Force -ErrorAction SilentlyContinue

持久檔預設位置: %APPDATA%MicrosoftPowerShellPSReadLineConsoleHost_history.txt (pwsh 7) 或 ...MicrosoftWindowsPowerShellPSReadLine... (5.1). 注意: 清完後你貼的這行指令本身仍會被記進新的 history.