Running PowerShell Command from PowerShell 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 [email protected]

Leave a Comment

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top