PowerTip: Add Commands to PowerShell History

Doctor Scripto

Summary: Learn how to add commands to your Windows PowerShell command history.

Hey, Scripting Guy! Question I have been working in the Windows PowerShell console all day, and I have several commands I keep running. It requires a lot of up and down arrowing to retrieve them. How can I add them to the my command history?

Hey, Scripting Guy! Answer Use Get-History to retrieve a list of all the commands you have typed. Note the command numbers, then use Get-History, supply the specific command numbers, store the resulting object in a variable, and add the history via the variable:

$a = Get-History 11,12

Add-History $a

0 comments

Discussion is closed.

Feedback usabilla icon