How to clear the Command History in PowerShell window session

by [Published on 29 May 2014 / Last Updated on 29 May 2014]

Tip explains how to clear the command history from the current PowerShell Window session.

To get a list of commands you executed in a PowerShell Window session, we use “Get-History” PowerShell cmdlet. To clear the command history, you can use “Clear-History” as listed below:

To clear complete command history, type below command:

  • Clear-History

Each command, executed in the PowerShell Windows session, is assigned with an ID. To delete the commands with history IDs, use below command:

  • Clear-History -ID 12, 20

About Nirmal Sharma

Nirmal is a MCSEx3, MCITP and was awarded Microsoft MVP award in Directory Services. He is specialized in Directory Services, Microsoft Clustering, Hyper-V, SQL and Exchange and has been involved in Microsoft Technologies since 1994. In his spare time, he offers technical help by writing tips and articles. Nirmal can be reached at nirmal_sharma@mvps.org.

Featured Links