Whether I am onboarding a new client, or trying to figure out who is watching an email address in our organization – there is nothing more frustrating than trying to play “pin the alias on the mailbox.” One day I decided enough was enough and wrote some PowerShell to solve this problem.
How To List All Mailbox Aliases in Office 365 or Exchange Online
Even though the meat of this task is a single command – there is a bunch of the usual PowerShell fluff required to get connected to Office 365.
Install ExchangeOnlineManagement First
If you don’t already have the cmdlets needed to talk to Exchange Online, you will first need to bust open a PowerShell prompt and run:
Install-Module -Name ExchangeOnlineManagement
Once you have ExchangeOnlineManagement installed, save the following as GetAliases.ps1 (or whatever you want, doesnt matter, just as long as it has the .ps1 extension.
# Import The PowerShell module for Exchange Online Import-Module ExchangeOnlineManagement # Connect to Exchange Online Connect-ExchangeOnline -UserPrincipalName [email protected] # Export the list to CSV Get-Recipient | Select DisplayName, RecipientType, EmailAddresses | Export-Csv EmailAddresses.csv
Once you’ve saved the script – run it. It will save a .csv file local to where the script was run. I must warn you, however, that the output will be ugly as sin; but if you have more than 3 mailboxes, clicking through each one to figure out all the aliases associated with said mailboxes will be a laborious drudge of your time, and running the script will save you a ton of frustration.
So, the above script will collect all the mailboxes in your Exchange Onliine/Office 365 tenant, the associated aliases to each account, and spit that information into a .csv file that you can visually go through, or apply further after-processing.
Did this script work for you? Did you find it useful? Subscribe to our newsletter to get more scripts, alerts, tips and tricks!