Get-Mailbox PowerShell -Server vs -Servername

Why does the command

       get-mailbox -servername "MyExgServer" not work

                 where

       get-mailbox -server "MyExgServer" does work?

Would this be because the -server is the object of an exchange server and the -servername is a property of the Mailbox that is returned. Perhaps I need to use a where-object statement.

      get-mailbox | Where-Object {$_.servername -eq "MyExgServer"}

Just wanting to understand the difference in approach

March 17th, 2015 6:24pm

When you run "get-mailbox | Where-Object {$_.servername -eq "MyExgServer"}", you are essentially getting *all* the mailboxes first (up to the the first 1000 unless you set resultsize to unlimited), then from that looking for those mailboxes with that set as an attribute.  This is a client-side filter query

get-mailbox -server <server> should return the same number, but its a parameter that is quickly indexed and runs much faster of course. This is a server-side filter and runs much faster.

.


Free Windows Admin Tool Kit Click here and download it now
March 17th, 2015 7:14pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics