The “Hey, Scripting Guys!” blog has been retired. There are many useful posts in this blog, so we keep the blog here for historical reference. However, some information might be very outdated and many of the links might not work anymore.
New PowerShell content is being posted to the PowerShell Community blog where members of the community can create posts by submitting content in the GitHub repository.
Scripting Blog [archived]
Formerly known as the "Hey, Scripting Guy!" blog
Latest posts

How Can I Determine How Long It Takes a Script to Run?

Hey, Scripting Guy! Is there a good way to time how long it takes for a script to run? -- BN, Montreal, Canada Hey, BN. Probably the easiest way to do this is to let the script time itself. To accomplish that feat, set the first line of the script to this: This code simply sets the value of the variable dtmStart to the current date and time. Now, make the last two lines of the script look like this: What does that do for us? Well, now we’ve saved the time the script began and the time the script ended. To determine how long it took for the script to run, we just need to subtract the beginning time from ...