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