Exporting and Importing PowerShell History

by Nov 8, 2013

PowerShell keeps a list of all commands you enter, but once you close PowerShell, the list is lost.

Here is a simple one-liner that saves the current command history to file:

Once you start a new PowerShell console or ISE editor instance, you can load the saved history back into PowerShell:

Unfortunately, the loaded history will not influence the keyboard buffer, so pressing ARROWUP or ARROWDOWN won't show the newly imported history items. However, you can use tab completion to find lines you entered before:

#(KEYWORD) <-Now press (TAB)!

Twitter This Tip! ReTweet this Tip!