The 2011 Scripting Games Beginner Event 10: Use PowerShell to Measure Time to Complete a Command


2011 Scripting Games badge

Summary: Beginner Event 10 in 2011 Scripting Games uses Windows PowerShell to determine the amount of time a command takes to complete.

About this event



Date of Event

4/15/2011 12:01 AM

Due Date

4/22/2011 12:01 AM

Event scenario

Your boss is working on a script that needs to halt execution for five seconds and then check a specific value. In the course of writing the script, your boss became concerned about the accuracy of using the Start-Sleep Windows PowerShell cmdlet to halt execution for five seconds. The script is not going to be used to control a space probe to mars, but it should be more accurate than a traditional egg timer. To be assured of the accuracy of the Start-Sleep command, your boss asks that you measure the time the Start-Sleep command takes to pause for five seconds. To check for variation, your boss wants you to take five measurements and provide the average time in milliseconds. A satisfactory output could be as simple as seen here.

Average time of 5 runs of 5 seconds is 5007.84288 milliseconds

Design points

  • Extra points for the use of variables to allow for other scenarios than the one in this event
  • Extra points for clean code
  • Extra points for formatting output

2011 Scripting Games: All Links on One Page

Submit your scripts on PoshCode

Support our Sponsors!

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy


Comments are closed. Login to edit/delete your existing comments