Running (mailbox) lists all M365 EXO mailboxes

Hello all,

I discovered some strange behavior this morning with the ExchangeOnlineManagement module from the PSGallery, and joined the forums to see if one the wizards here can tell us what’s going on.

After importing the module and connecting to EXO tenant, we discovered that issuing (mailbox) in the shell will list all the mailboxes in the tenant as if running the Get-Mailbox cmdlet with unlimited results. However, Get-Command does not find a command or function for mailbox.

Steps to reproduce the behavior:

# Install the module
Install-Module -Name ExchangeOnlineManagement -Force
# Connect to EXO and log in
Connect-ExchangeOnline

# List all mailboxes for the tenant
Get-Mailbox -ResultSize Unlimited

# Running (mailbox) returns the same output as the above cmdlet (see screenshot below)
(mailbox)

Get-Command -Name "mailbox" # returns an error

Screenshot for reference:

Enclosing the “mailbox” in parenthesis I believe is performing some sort of sub-expression or evaluating the expression first before executing the next step. Similar to member access enumeration, the object is enumerated first, and then the property is accessible (Please correct me here if I’m mistaken). What is strange in this instance, mailbox is not a cmdlet, function, or script, so it fails. However, running it in parenthesis returns all mailboxes.

Also to note, the ExchangeOnlineManagement module when imported adds the module as expected. However, once connecting to ExchangeOnline, it imports a temporary module. I tried to do my due diligence before posting here, and made sure to review all the cmdlets and functions in each module first, but no luck.

Any insight to understand what is going here will be greatly appreciated! Thank you!

As a new member, I’m limited to one screenshot per post. Please let me know if you need any additional information, and I’ll be happy to provide. Thanks again.

trainmore,
Welcome to the forum. :wave:t3:

That’s called implicit alias and works - if I remember correct - with all get cmdlets. For example Get-ChildItem and ChildItem or Get-Date and Date or Get-Volume and Volume or Get-Service and Service and so on and on and on.

The third sentence of this article describes it:

But as the title of this article already hints “Avoid Using Cmdlet Aliases!” :point_up_2:t3: :wink:

1 Like

Wow. Thank you for sharing. I’m not sure I would have ever found that out on my own.

TIL about implicit aliases. Very strange that implicit aliasing is missing from the about_Aliases help page, or even the ‘Using aliases’ page.