Invoke-History

Runs commands from the session history

Syntax
      Invoke-History [[-iD] string] [-whatIf] [-confirm] [CommonParameters]

Key
   -iD The ID number or the first few characters of a command
       from the session history.
	   
   -whatIf
       Describe but dont actually execute the command.

   -confirm
       Prompt for confirmation before executing the command.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

To find the ID number of a command, use Get-History.
You can pipeline commands from Get-History directly to Invoke-History.

Examples

Run the last (most recent) command:

PS C:\>r

Run the most recent get- command in the session history:

PS C:\>invoke-history get-

Run commands 5 - 15 and 17: (separate multiple IDs with commas)

PS C:\>invoke-history (5..15), 17

"Spam will be a thing of the past in two years’ time" - Bill Gates, 2004

Related:

Add-History - Add entries to the session history
Get-History
- Get a listing of the session history
Equivalent bash command: history - Command Line history



Back to the Top

© Copyright SS64.com 1999-2010
Some rights reserved