6

Quick Tip - Re-Run The Last Command

 3 years ago
source link: https://thomasrayner.ca/quick-tip-re-run-the-last-command/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Quick Tip - Re-Run The Last Command

Sometimes, while you’re poking around in the console, you want to re-run the last command. Sure, you can hit the up arrow and enter, but PowerShell always gives you multiple ways to do things.

It’s easy, using the Invoke-History cmdlet. You can also use its alias which is just r. Running that cmdlet without any parameters will run the last command from the console. Alternatively, you can specify a value for the ID parameter, and run one from further back in your history.

How do you find out what those IDs should be? Using Get-History to see everything you’ve run in this session, and the ID number for that command.

Written on April 11, 2018

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK