Get-Mailbox PowerShell -Server vs -Servername RRS feed

  • Question

  • Why does the command

           get-mailbox -servername "MyExgServer" not work


           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

    Tuesday, March 17, 2015 10:23 PM


  • 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.


    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

    • Marked as answer by BTRowdy1 Wednesday, March 18, 2015 4:24 PM
    Tuesday, March 17, 2015 11:13 PM