Time your Powershell Commands

Task:  You want to measure your Powershell commands so you can time your commands for efficiency. In the example below, I want to time how fast my results are returned for finding all Mailboxes in our organization.

Resolution:   Select from #Start to #End and copy and paste it all into PowerShell. Make sure you paste it all at once.  It will execute the start and end time variables and then subtract it.  It will then display the $total in these various units of measure; TotalMilliseconds, TotalSeconds, TotalMinutes, TotalHours, TotalDays, and Ticks.

#Start
$Start = Get-Date
Get-Mailbox -resultsize unlimited
$End = Get-Date
$total = $End-$Start
$total
#End

Advertisement

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 )

Connecting to %s

%d bloggers like this: