Powershell - Invoke-History Cmdlet


Advertisements

Cmdlet

Invoke-History cmdlet is used to run the command from the current session which are already run.

In these example, we're see the Invoke-History cmdlet in action.

Example

In this example, we'll show how to invoke last run command using Invoke-History. Call Invoke-History without parameter.

Invoke-History
Measure-Command { Get-EventLog "Windows PowerShell" }

Output

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 11
Ticks             : 116083
TotalDays         : 1.34355324074074E-07
TotalHours        : 3.22452777777778E-06
TotalMinutes      : 0.000193471666666667
TotalSeconds      : 0.0116083
TotalMilliseconds : 11.6083
powershell_advanced_cmdlets.htm
Advertisements