One Day Sec

How can administrators defend against the exposure of sensitive information in PowerShell command history?

For Windows 10 and later (PowerShell v5), periodically clear the persistent history file at `%appdata%\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt` using `Remove-Item (Get-PSReadlineOption).HistorySavePath`. For older PowerShell versions, use `Clear-History` to erase the current session. For cmd.exe, run `doskey /reinstall` to clear command history. Prompt removal of sensitive commands (e.g., those containing passwords) helps prevent credential leakage.
defenseclear historyRemove-ItemClear-Historydoskeycredential protection

Browse all Q&A →