CmdID

CmdID / PowerShell / Cmdlets / Invoke

Invoke-History

Runs commands from the session history. PowerShell reference

From the PowerShell reference 3 parameters Aliases ihy, r

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Runs commands from the session history. The Invoke-History cmdlet runs commands from the session history. You can pass objects representing the commands from Get-History to Invoke-History, or you can identify commands in the current history by using their Id number. To find the identification number of a command, use the Get-History cmdlet. The session history is managed separately from the history maintained by the PSReadLine module. Both histories are available in sessions where PSReadLine is loaded. This cmdlet only works with the session history. For more information see, about_PSReadLine.

Invoke-History [[-Id] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Run the most recent command in the history

Invoke-HistoryIdentify

Run the command that has a specified ID

Invoke-History -Id 132Identify

Run the most recent command by using the command text

Invoke-History -Id get-prIdentify

Run a sequence of commands from the history

16..24 | ForEach-Object {Invoke-History -Id $_ }Identify

Example 5

Get-History -Id 255 -Count 7 | ForEach-Object {Invoke-History -Id $_.Id}Identify

Its page in the reference: Invoke-History.

Parameters

3 in the PowerShell reference
-IdSpecifies the Id of a command in the history. You can type the Id number of the command or the first few characters of the command. If you type characters, Invoke-History matches the most recent commands first. If you omit this parameter, Invoke-History runs the last, or most recent, command. To find the Id number of a command, use the Get-History cmdlet.
-ConfirmPrompts you for confirmation before running the cmdlet.
-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.