Time your script

I’m back with another set of small helper functions. This time it’s all about timing your script. Sure, it’s not that difficult to do manually – just get the time when it starts, and when it ends, and calculate the running time. It might not look pretty, but it works. With this functions though, it’s even easier!

The two functions are pretty self-explanatory, but let’s give a very simple example of how it can be used:

Write-Host "Script started at $(Start-Timer)"

# YOUR CODE GOES HERE

Write-Host "Script ended in $(Stop-Timer)"

Easy, eh?

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