Clearing Command and Buffer History in Powershell

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 Reply

Your email address will not be published. Required fields are marked *

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