Windows

Clearing Command and Buffer History in Powershell

January 15, 2015 Rich 1 min read

Clear Powershell’s last 10 commands:

clear-history -count 10 -newest

After executing that, use get-history to see what’s left…
Clear the console buffer by scripting F7+2:

[system.reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::Sendwait('%{F7 2}')

Try using the Up key to cycle through history — won’t happen.

Leave a comment