Get-History - PowerShell


 

Gets a list of the commands entered during the current session. (Get-History)

   

# NAME
Get-History

# SYNOPSIS
Gets a list of the commands entered during the current session.

# SYNTAX
Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]

# DESCRIPTION
The Get-History cmdlet gets the session history, that is, the list of commands entered during the current session. Windows PowerShell automatically maintains a history of each session. You can save the session history in XML or CSV format. By default, history files are saved in the home directory, but you can save the file in any location.

# PARAMETERS
-Count <int>
Displays the specified number of the most recent history entries. The default is 32. If you use both the Count and Id parameters in a command, the display ends with the command specified by the Id parameter.

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Id <Int64[]>
Specifies the ID number of a command in the session history. Get-History gets only the specified command. If you use Id and Count, Get-History gets the most recent commands ending with the command specified by the Id parameter.

Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
Int64
You can pipe a history ID to Get-History.

# OUTPUTS
Microsoft.PowerShell.Commands.HistoryInfo
Get-History returns a history object for each history item that it gets.

# NOTES

The session history is a list of the commands entered during the session along with the ID. The session history represents the order of execution, the status, and the start and end times of the command. As you enter each command, Windows PowerShell adds it to the history so that you can reuse it. For more information about the command history, see about_History.

You can also refer to Get-History by its built-in aliases, "h", "history", and "ghy". For more information, see about_Aliases.

# EXAMPLE 1

C:\PS>get-history

# Description
-----------
This command gets the 32 most recently submitted commands. The default display shows each command and its ID, which indicates the order of execution.

# EXAMPLE 2

C:\PS>get-history | where-object {$_.commandLine -like "*service*"}

# Description
-----------
This command gets entries from the command history that include the word, "service". The first command gets the 32 most recent entries in the session history. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the commands that include "service".

# EXAMPLE 3

C:\PS>get-history -id 7 -count 5 | export-csv history.csv

# Description
-----------
This command gets the five most recent history entries ending with entry 7. The pipeline operator (|) passes the result to the Export-Csv cmdlet, which formats the history as comma-separated text and saves it in the History.csv file. The file includes the data that is displayed when you format the history as a list, including the status and start and end times of the command.

# EXAMPLE 4

C:\PS>get-history -count 1

# Description
-----------
This command gets the last (most recently entered) command in the command history. It uses the Count parameter to display just one command. By default, Get-History displays the most recent commands. This command can be abbreviated to "h -c 1" and is equivalent to pressing the up-arrow key.

# EXAMPLE 5

C:\PS>get-history -count $MaximumHistoryCount

# Description
-----------
This command displays all of the commands saved in the session history. By default, $MaximumHistoryCount is 64, so this command can be abbreviated as "h -c 64".

# EXAMPLE 6

C:\PS>get-history | format-list

# Description
-----------
This command displays all of the properties of entries in the session history. The pipeline operator (|) passes the result to the Format-List cmdlet, which displays all of the properties of each history entry, including the ID, status, and start and end times of the command.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113317
about_history
Invoke-History
Add-History
Clear-History

C:\Windows>powershell get-help Invoke-History -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole








Windows-10





Windows-10

... facebook.de
... Windows-10 FAQ
... Windows-10 Info


Become a Sponsor
... Your button here?





PowerShell: Gets a list of the commands entered during the current session.

HTTP: ... PS_Windows/en/Get-History.htm
0.187
12542

Can I grant a directory / directory access for a program under Windows 10 Explorer?

 /

For the Greens and Greenpeace just the right desktop clock!

 /

Windows 7 direct download links all versions!

 /

Do i have windows 10 x86, x64 or x32 and 32 or 64 Bit?

 /

Formatieren über die Eingabeaufforderung Windows (10,8.1, 7)!

 /

What is the difference between Windows 7 Ultimate x64 to x86?

 /

Set a limit for maximum used RAM memory on Windows 10/8.1/7, can I?

 /

Can I enable Server 2016 Virtualization on Windows 10?

 /

Task Manager Desktop shortcut, start minimized in Windows 8.1 / 10!

 /

After upgrade, user switching does not show why Windows 10?

 /

How to delete files without the Recycle Bin in Windows 7, 8.1, 10?

 /

What are variables?

 /