CmdID

CmdID / PowerShell / Cmdlets / Add

Add-History

Appends entries to the session history. PowerShell reference

From the PowerShell reference 2 parameters

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

Appends entries to the session history. The Add-History cmdlet adds entries to the end of the session history, that is, the list of commands entered during the current session. The session history is a list of the commands entered during the session. The session history represents the order of execution, the status, and the start and end times of the command. As you enter each command, PowerShell adds it to the history so that you can reuse it. For more information about the session history, see about_History. 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. You can use the Get-History cmdlet to get the commands and pass them to Add-History, or you can export the commands to a CSV or XML file, then import the commands, and pass the imported file to Add-History. You can use this cmdlet to add specific commands to the history or to create a single history file that includes commands from more than one session.

Add-History [[-InputObject] <PSObject[]>] [-PassThru] [<CommonParameters>]

Add commands to the history of a different session

Get-History | Export-Csv -Path C:\testing\history.csv -IncludeTypeInformation Import-Csv -Path C:\testing\history.csv | Add-HistoryIdentify

Import and run commands

Import-Clixml -Path C:\temp\history.xml | Add-History -PassThru | ForEach-Object -Process {Invoke-History}Identify

Add commands in the history to the end of the history

Get-History -Id 5 -Count 5 | Add-HistoryIdentify

Add commands in a .csv file to the current history

$a = Import-Csv -Path C:\testing\history.csv Add-History -InputObject $a -PassThruIdentify

Add commands in an .xml file to the current history

Add-History -InputObject (Import-Clixml -Path C:\temp\history.xml)Identify

Its page in the reference: Add-History.

Parameters

2 in the PowerShell reference
-InputObjectSpecifies an array of entries to add to the history as HistoryInfo object to the session history. You can use this parameter to submit a HistoryInfo object, such as the ones that are returned by the Get-History, Import-Clixml, or Import-Csv cmdlets, to Add-History.
-PassThruIndicates that this cmdlet returns a HistoryInfo object for each history entry. By default, this cmdlet does not generate any output.