Running PowerShell Command from PowerShell History

by [Published on 13 Aug. 2014 / Last Updated on 13 Aug. 2014]

Tip explains how you can run PowerShell commands from session history.

PowerShell maintains the history of commands in session history. You can use Invoke-History PowerShell cmdlet to run command from the session history as shown below:

  • Invoke-History

This command runs the last command in the session history.

  • Invoke-History –ID 12

The above command runs command which is tagged with ID 12 from session history.

  • Invoke-History Get-Pr

The above command runs the most recent Get-Process command from the session history.

About Nirmal Sharma

Nirmal is a MCSEx3, MCITP and was awarded Microsoft MVP award in Directory Services. He is specialized in Directory Services, Microsoft Clustering, Hyper-V, SQL and Exchange and has been involved in Microsoft Technologies since 1994. In his spare time, he offers technical help by writing tips and articles. Nirmal can be reached at

See Also

The Author — Nirmal Sharma

Nirmal Sharma avatar

Nirmal Sharma is a MCSEx3, MCITP, and was awarded Microsoft MVP in Directory Services. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles for various online communities. Nirmal can also be found contributing to PowerShell based Dynamic Packs for ADHealthProf.ITDynamicPacks.Net solutions.

Featured Links