CmdID / PowerShell / Cmdlets / Add
Add-History
Appends entries to the session history. PowerShell reference
From the PowerShell reference 2 parameters
What it does
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-HistoryIdentifyImport and run commands
Import-Clixml -Path C:\temp\history.xml |
Add-History -PassThru |
ForEach-Object -Process {Invoke-History}IdentifyAdd commands in the history to the end of the history
Get-History -Id 5 -Count 5 | Add-HistoryIdentifyAdd commands in a .csv file to the current history
$a = Import-Csv -Path C:\testing\history.csv
Add-History -InputObject $a -PassThruIdentifyAdd commands in an .xml file to the current history
Add-History -InputObject (Import-Clixml -Path C:\temp\history.xml)IdentifyIts page in the reference: Add-History.
Parameters
-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.