Home PowerShell - Where is the command history stored?
Post
Cancel

PowerShell - Where is the command history stored?

Table of Contents

All commands entered in a PowerShell console are saved in a single file located in the current user’s app data directory. This feature is helpful for referencing previous commands, but it can pose a security risk if sensitive information, such as passwords or user data, is entered in plain text. To protect this information, use secure objects like PSCredential for usernames and passwords.

You can find the file here:

C:\Users\%username%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline

To prevent your commands from being saved to this file, you can add the following to your PowerShell profile.ps1 file to disable it permanently, or just enter it in your console to disable it for the current session.

Set-PSReadlineOption -HistorySaveStyle SaveNothing
https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption
This post is licensed under CC BY-SA 4.0 by David Marker