Clear PowerShell History on Windows

Clear PowerShell History on Windows

PowerShell is a command line tool used on Windows operating systems to automate tasks and manage system configurations. It maintains a history of executed commands, making it convenient to revisit and reuse them. However, there are instances where you may want to clear this history, perhaps for privacy or security reasons. This tutorial demonstrates how to clear PowerShell history on Windows.

The Clear-History cmdlet in PowerShell is designed to clear the command history for the current session only. However, if you want to clear the entire history in PowerShell, you need to delete the file where previous commands are stored.

You can utilize (Get-PSReadlineOption).HistorySavePath to retrieve the location of the PowerShell command history file. To clear PowerShell history, simply delete the file found at this location:

Remove-Item (Get-PSReadlineOption).HistorySavePath

Reopen PowerShell window. Your PowerShell history is now cleared, providing a clean state for future commands.

Leave a Comment

Cancel reply

Your email address will not be published.