Skip navigation

Q. How do I determine exactly how long a cmdlet or script block will take to execute in Windows PowerShell?

A. You can use the Measure-Command cmdlet to display a cmdlet's or script block's exact execution time. The following command and output shows the time it takes to execute the Get-Services cmdlet:

Users\john> measure-command \{get-service\}

The output would be:

Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 12
Ticks : 120351
TotalDays : 1.39295138888889E-07
TotalHours : 3.34308333333333E-06
TotalMinutes : 0.000200585
TotalSeconds : 0.0120351
TotalMilliseconds : 12.0351

The output from the actual command (Get-Services) isn't shown, so you'd pipe that output to a file.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.