PowerShell Logo Small

Invoke-History



This is the built-in help made by Microsoft for the command 'Invoke-History', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Runs commands from the session history.

SYNTAX


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



Search powershellhelp.space

DESCRIPTION


The Invoke-History cmdlet runs commands from the session history. You can pass objects representing the commands from Get-History to Invoke-Histo
ry, or you can identify commands in the current history by using their ID number. To find the identification number of a command, use Get-History
.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113344
about_History
Get-History
Add-History
Clear-History

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-history



Description
-----------
This command runs the last (most recent) command in the session history. You can abbreviate this command as "r" (think "repeat" or "rerun"), the
alias for Invoke-History.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-history -id 132



Description
-----------
This command runs the command in the session history with ID 132. Because the name of the Id parameter is optional, you can abbreviate this comma
nd as "Invoke-History 132", "ihy 132", or "r 132".








-------------------------- EXAMPLE 3 --------------------------

C:\PS>invoke-history get-pr



Description
-----------
This command runs the most recent Get-Process command in the session history. When you type characters for the Id parameter, Invoke-History runs
the first command that it finds that matches the pattern, beginning with the most recent commands. This command uses the ID parameter, but it omi
ts the optional parameter name.








-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-history (16..24), 27



Description
-----------
This command runs commands 16 through 24 and 27. You can list multiple IDs and ID ranges separated by commas.








-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -id 255 -count 7 | invoke-history



Description
-----------
This command runs the 7 commands in the history that end with command 255 (typically 249 through 255). It uses the Get-History cmdlet to retrieve
the commands. The pipeline operator (|) passes the commands to Invoke-History, which executes them.