PowerShell: Get a Cmdlet or Script’s Execution Time

PowerShell allows you to get the exact execution time it would take to run a cmdlet or script. This is useful if you are working with a small window of time in which to run the script.


1. Open PowerShell

2. To get the execution time, you will use the Measure-Command cmdlet. Here’s an example for getting the execution time for the Get-Process cmdlet:
measure-command {get-process}

3. Once you have executed the measure-command cmdlet, the execution time will be displayed in Days, Hours, Minutes, Seconds, Milliseconds, Ticks, TotalDays, TotalHours, TotalMinutes, TotalSeconds and TotalMilliseconds.

 

About Rob Rogers

Once a prolific author here on Tech-Recipes, Rob has moved on to greener pastures.
View more articles by Rob Rogers

The Conversation

Follow the reactions below and share your own thoughts.

  • Rick

    Who would want to display all that gobbledy-gook. What would be useful would be an example of how to show something like:

    My process took x minutes and y seconds.

    How would you use measure-command to do that?

  • Luis

    @Rick, dont expect people to do your job, you found a great command, now you can search on google and find a way to concatenate strings and show what you need, at least DO SOME RESEARCH.