Saturday, 13 June 2015

PowerShell - Get-Mailbox ResultSize

The Exchange PowerShell cmdlet Get-Mailbox is one of the most useful and powerful command to retrieve all the properties for all the Mailboxes from your Exchange Server 2010/2013.

If you have more than 1000 mailboxes and execute the command Get-Mailbox, you will get first 1000 Mailboxes and followed by the following warning message:
WARNING: By default only the first 1000 items are returned. To change the number of items returned, specify the parameter "-ResultSize". To return all items specify "-ResultSize Unlimited" (Note: Returning all items may take a very long time and consume a large amount of memory depending on the actual number of items). It is not recommended to store the results in a variable; instead pipe the results to another task or script to perform batch changes
As per the warning message, this command will only return the first 1000 Mailboxes. You can change this by adding -ResultSize Unlimited to get all the Mailbox details
Get-Mailbox -ResultSize Unlimited
If you want to get only first 100 Mailboxes, add the value 100 in ResultSize.
Get-Mailbox -ResultSize 100
You can also get only first 100 mailboxes with other method using Select-Object.
Get-Mailbox | Select-Object -First 100
In this way, you can also get second 100 mailboxes by adding -Skip parameter.
Get-Mailbox | Select-Object -Skip 100 -First 100 
The above command returns second 100 Mailbox details in between 101 to 200.


No comments:

Post a Comment