Clearing Command and Buffer History in Powershell

This content 5 years old. Please, read this page keeping its age in mind along with the fact technology changes fast and the information on this page me be outdated, not best practice, or plain wrong.

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.

Speak Your Mind

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.