Runs commands from the session history

      Invoke-History [[-id] string]
         [-whatIf] [-confirm] [CommonParameters]

       The ID number, or the first few characters of a command in the
       session history.

       Describe what would happen if you executed the command without
       actually executing the command.

       Prompt for confirmation before executing the command.

Standard Aliases for Invoke-History: r, ihy

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


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 PowerShell Cmdlets

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

Copyright © 1999-2024
Some rights reserved