How to Use Filters with the Get-ExoMailbox Cmdlet?

Summary: Administrators can use the Get-ExoMailbox cmdlet to view the mailbox objects, attributes, populate the property pages and supply mailbox information. In this article, you will learn how to use the Get-ExoMailbox cmdlet with filters and additional parameters to optimize your queries and view desired information.

The Get-ExoMailbox command is faster than the Get-Mailbox command for retrieving mailbox data. When it comes to getting information from a system which has hundreds or thousands of mailboxes, it?s easier and quicker to retrieve the data. But when having this much of mailboxes, it?s best to prioritize and optimize accordingly. In this article, we will see how to use the filtering options with the Get-ExoMailbox command to optimize our queries.

Filtering Data with Get-ExoMailbox Command

We can optimize our queries and commands to get the right data with fast results. The Get-ExoMailbox command offers various filter options that can help us select the right group of mailboxes, rather than going through all the mailboxes. There are two variants when working with filters: client-side and server-side.

The server-side filters are processed on the server first and then the data with the result is sent back to the user querying the server. When the client-side filter is chosen, the bulk of the data is quickly provided by the server to the device affecting the command, and then the filtering and processing of the required information is done at the client-side. Normally, we tend to go for the server-side filtering for best performance. When we process from the client-side on a laptop, we cannot match the processing power of the server. When we run a command on the server, unless it?s a loop which is filtering through all the servers with huge nested loops, it will not affect the server?s performance.

How to Filter the Data?

We need to first understand when the server-side and client-side is used.

The server-side command is without any pipes and used with the Filter switch (see the below example).

Get-ExoMailbox -Filter {Office -eq "Main"}

This command will fetch all the mailboxes which have the Office parameter set as Main.

The client-side counterpart for this command is:

Get-ExoMailbox | ? {$_.Office -eq "Main"}

Since the client-side filtering is done at destination of the command executable, in the example above, the Exchange Server will load all the mailboxes and their Office parameters, pass all the information to the destination of the command, and then the filtering of the mailboxes to load the ones of Main will be done by the client. The above command will not work alone. When we run the Get-ExoMailbox command alone, it will not retrieve the property of the Office with it. For this, we need to use the command as given below.

Get-ExoMailbox -Properties Office | ? {$_.Office -eq "Main"}

We can have more switches in the server-side property. These commands will also be processed on the server-side. This will create a more precise query and reduce the amount of processing time on the client.

For example; we can add the recipient type in the command.

Get-ExoMailbox -Properties Office -RecipientTypeDetails UserMailbox | ? {$_.Office -eq "Main"}

This will return all user mailboxes along with their properties, excluding the rest. When we want to optimize our query, it would be best to also look into limiting the number of results. If we wish to have a sample or just one element, the query will stop processing once the criteria are met. For this, we need to use the Result Size parameter as given below.

Get-ExoMailbox -Properties Office -RecipientTypeDetails UserMailbox -ResultSize 100 | ? {$_.Office -eq "Main"}

This will surely speed up the process of getting the results and reduce the load on the server/client. We can also add multiple properties by separating them with commas (see the below example).

Get-ExoMailbox -Properties Office, Name -RecipientTypeDetails UserMailbox -ResultSize 100 | ? {$_.Office -eq "Main"}

In case we need to retrieve information for a specific mailbox, we need to add the Identity switch to the command.

Get-ExoMailbox -Identity <email address> -Properties <property name>

There are other switches we can use, such as:

Archive
GroupMailbox
InactiveMailboxOnly
IncludeInactiveMailbox
Migration
OrganizationalUnit
PropertySets
PublicFolder
SoftDeletedMailbox

More information can be found by running the below command.

Help Get-ExoMailbox

Conclusion

Above, we have seen how to use the Get-ExoMailbox command. With this command, we can get information on sizes, number of items, and other information. This also gives us a report of missing data, if we have from a migration process. To migrate the missing data with full filtering and other features, the best way is to use an EDB to PST application like Stellar Converter for EDB. We can use this application to open multiple EDB files from any version of Exchange Server without having Exchange Server installed. We can easily export mailboxes, archives, disabled mailboxes, shared mailboxes, and public folders to PST, a live Exchange Server, or Office 365 with ease.

Related Post