#PowerShell Timing How Long it Takes a Script to Run

If you’ve ever wondered how long it takes to perform a specific task then the Measure-Command cmdlet is exactly what you’ve been looking for: it enables you to measure the running time of a command or script down to the millisecond.

Measure-Command {Get-Service | Export-Clixml c:\scripts\test.xml}

When you run this command, service information will be saved to the file Test.xml; in addition, Measure-Command will report back information similar to this:
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 971
Ticks             : 9717422
TotalDays         : 1.12470162037037E-05
TotalHours        : 0.000269928388888889
TotalMinutes      : 0.0161957033333333
TotalSeconds      : 0.9717422
TotalMilliseconds : 971.7422

http://technet.microsoft.com/en-us/library/ee176899.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s