O-Xchange Notes from the Field!

Tuesday, November 4, 2014

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

No comments:

Post a Comment