PoshTip #5 – Measure your Powershell script
First method
PowerShell has a built in command Measure-Command. It is a great cmdlet to quickly find how much a command takes to execute.
1 |
Measure-Command { Get-Process } |
If you want to see the output
1 |
Measure-Command { Get-Process | Out-Default } |
Second method
You can also use the .NET Stopwatch object
1 2 3 4 |
$MeasureCMD = [Diagnostics.Stopwatch]::StartNew() Get-Process $MeasureCMD.Stop() $MeasureCMD.Elapsed |