Quite often, I see questions like “Why is my Get-Recipient command so slow?”, with a syntax like:
You would think that would work lickity split, because there is only 1 result, me.
Ah, not so fast, grasshopper. We are doing client side filtering – all recipients are returned by the Get-Recipient call, and THEN we pass those objects to the Where-Object.
On my Exchange 2007 system, this takes over a minute to return my information in $user1
So, I did some research, and read about –Filters and doing server side filtering:
Modifying my script to use the –Filter produces results in less than 1 second:
I suggest that you check for the –Filter parameter for any cmdlet that you use, and learn its syntax!