Add-History

Add entries to the end of the session history (the commands entered during the current session).

Syntax
      Add-History [[-inputObject] PSObject[]] [-passthru] [CommonParameters]

key
    -inputObject PSObject[]
        Adds the specified HistoryInfo objects to the session history. You can 
        use this parameter to submit a HistoryInfo object from Get-History, Imp
        ort-Clixml, or Import-Csv to Add-History.

    -passthru SwitchParameter
        Passes the object created by this cmdlet through the pipeline. 
        By default, this cmdlet does not pass any objects through the pipeline.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Examples

Export session history to a file :

C:\PS>get-history | export-csv E:\SessionHist.csv

Import session history from a file (this could be a different session on a different machine):

C:\PS>import-csv SessionHist.csv | add-history

You can also pipe commands directly from get-history to add-history which will re-arrange the order of items in the command line history. Piping history command (either from file or from get-history) to invoke-history will actullly run the commands.

“History teaches us that men and nations behave wisely once they have exhausted all other alternatives” - Abba Eban

Related:

Get-History
invoke-history
Equivalent bash command: history - Command Line history


© Copyright SS64.com 1999-2014
Some rights reserved