Scripting Blog

A place to learn about PowerShell and share stories of automation

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: dtmStart = Now This code simply sets the value of the variable dtmStart to the ...

How Can I Get Yesterday’s Date?

Hey, Scripting Guy! I’m writing a script, and I need to know yesterday’s date. I can use Date() to figure out today’s date, but how do I figure out yesterday’s date?-- SS Hey, SS. You’re right; it’s easy to determine today’s date using a script:dtmToday = Date() Wscript.Echo dtmToday But what about yesterday’s date? Listen, ...