PowerShell Get or Invoke History: h and r prefix

Quickly locate past commands without having to scroll through with the Up Arrow key. 
http://technet.microsoft.com/en-us/magazine/hh241048.aspx
get-history | where { $_.CommandLine -like '*select*' }
Use the StartExecutionTime and EndExecutionTime properties to measure the time it took to complete a command. For example: get-history | select commandline,executionstatus,startexecutiontime,endexecutiontime,@{n='ExecutionDuration';e={$_.EndExecutionTime- $_.StartExecutionTime}}
Get-History | Foreach-Object { Invoke-History –id $_.id }

Invoke-History: Aliases: ihy, r
http://www.activexperts.com/activmonitor/windowsmanagement/powershell10/0061/
Run the last (most recent) command: just r
Run the most recent get- command in the session history: invoke-history get- or r get-
invoke-history (5..15), 17
Invoke-History 3;Invoke-History 4

r "git push"
The Last Command:  $^
PowerShell will store the last command executed into the $^ variable.
Repeat last command: &$^
Get-Command -Noun history

No comments:

Post a Comment