PowerShell Measure-Command

Working on some PowerShell scripting timing issues and documentation of how long things are taking and what they are doing while this is happening was needed. In this case put Measure-Command commands throughout the scripts to determine the timings.

Example usage

In this example I am using a oneline batch file that takes a command line argument and then waits that amount of time (in seconds) before returning.

Batch file contents TIMEOUT /T %1

Expected run results

.\wait.bat 5

C:\projects\html5>TIMEOUT /T 5

Waiting for 0 seconds, press a key to continue ...

Now wrap this in a Measure-Command and make sure to pipe the current command output to the output so you know what is happening while it is running like above Measure-Command { .\wait.bat 5 | Out-Host }

Expected run results

Measure-Command { .\wait.bat 5 | Out-Host }

C:\projects\html5>TIMEOUT /T 5

Waiting for 5 seconds, press a key to continue ..0


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 4
Milliseconds      : 267
Ticks             : 42673978
TotalDays         : 4.93911782407407E-05
TotalHours        : 0.00118538827777778
TotalMinutes      : 0.0711232966666667
TotalSeconds      : 4.2673978
TotalMilliseconds : 4267.3978

The timing seem off because it was supposed to wait 5 seconds, but I suppose that is a side effect of the timeout command I am running