How To Clear Your PowerShell cmdlets History

In this blog post, I will show you how to clear you PowerShell cmdlets history from the console and session.


The PowerShell cmdlets that give us the ability to clear the history of all of our cmdlet is clear-history which can be very useful in many use cases or part of an automated process or as a security measurement to clear all the cmdlets that an administrator has used.


In case you need to clear the last cmdlet you can simply use the following cmdlet as shown below.

clear-history -count 1 -newest 

To delete a specific cmdlet from the history you can use the following cmdlet instead of clearing the entire session history of cmdlets.

Clear-History -CommandLine *cls*

Success! You're on the list.