Using wildcards with Get-Mailbox and the other Get- cmdlets in Exchange!

Just watched the Clutter session from Ignite, and a hidden gem appeared – it seems that you can use wildcards with Get-Mailbox and most (all?) of the other Get- cmdlets. Like this:

PS C:\> Get-Mailbox v*

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
vasil vasil dbxpr03mb617 49.5 GB (53,150,220,288 bytes)

It’s not limited to leading wildcards only:

PS C:\> Get-Mailbox *search*

Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
DiscoverySearchMailbox... DiscoverySearchMa... dbxpr03mb239 50 GB (53,687,091,200 bytes)

And you can use it with other Get- cmdlets as well:

PS C:\> Get-Recipient *search*

Name RecipientType
---- -------------
DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E09334BB852} UserMailbox

It’s not something revolutionary, as we have always been able to use the server side filtering via the -Filter parameter or client-side via Where-Object. The simplicity of using wildcards with the Identity parameter however is tremendously helpful in my book, as people new to PowerShell are less likely to be confused by that, compared to using operators and such.

The Exchange gurus were quick to point out that this has been around like forever, working on versions as old as Exchange 2007. Michel de Rooij pointed out that when wildcards are involved, the attributes checked include Name, DisplayName, Alias and UserPrincipalName. The last one explains why only Mailbox objects are returned when you use an ’email’ string with the Get-Recipient cmdlet, such as:

PS C:\> Get-Recipient *@michev.onmicrosoft.com

Name RecipientType
---- -------------
DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E09334BB852} UserMailbox

I am yet to find any authoritative documentation on how the wildcard matching works, and the cmdlet help insists that the Identity parameter does not accept wildcards:

-Identity <MailboxIdParameter>

 The Identity parameter specifies the mailbox that you want to view. You can use any value that uniquely identifies the mailbox.

 For example:

 * Alias
 * Distinguished name (DN)
 * GUID
 * Name
 * Display name
 * LegacyExchangeDN
 * Email address
 Required? false
 Position? 1
 Default value
 Accept pipeline input? True
 Accept wildcard characters? False

Somebody needs some spanking!

P. S. In case you haven’t figured it out yet, blogging stuff is my way of making sure I will never forget about a feature. So apologies if this has been another useless post from your perspective 🙂

3 thoughts on “Using wildcards with Get-Mailbox and the other Get- cmdlets in Exchange!

    1. swissbuechi says:

      Did you use it with “ResultSize Unlimited”?
      Otherways it maybe does not show all matched entries.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.