Often, Microsoft 365 admins want to export all email addresses in their Microsoft 365 environment. You can use the PowerShell cmdlets like Get-Mailbox, Get-Recipient to retrieve Primary email addresses and aliases. Since each type of mailbox requires different cmdlets or filtering conditions, it is always challenging to find the right one.
Since Microsoft allows sending emails from alias addresses, admins need a record of alias addresses. To easily export all the email addresses, you can download our script. Also, our script lets you use the built-in filtering params to retrieve the email addresses of each type of mailbox.
Script Download: GetAllOffice365EmailAddresses.ps1
- The script uses modern authentication to connect to Exchange Online.
- The script can be executed with MFA enabled account too.
- Exports report results to CSV file.
- Allows you to generate email address report for a specific mailbox type, such as user mailbox, shared mailbox, guest users, contacts, etc.
- Automatically installs the EXO V2 module (if not installed already) upon your confirmation.
- The script is scheduler friendly. I.e., Credential can be passed as a parameter instead of saving inside the script.
The exported report contains following attributes: Display Name, Recipient Type Detail, Primary SMTP Address, Alias Email Address.
To run the script, you can choose any one of the methods below.
Method 1: Execute the script with MFA and non-MFA accounts
Method 2: Execute the script by explicitly mentioning the credentials.
.\GetAllOffice365EmailAddresses.ps1 -UserName Admin@contsoso.com -Password XXX
Note: Scheduling works only for non-MFA accounts. If the admin account has MFA, you need to disable MFA based on the Conditional Access policy to make it work.
Our script supports multiple in-built advanced filtering parameters, which allows admins to view email addresses based on their requirements. With this script, you can
- Get all email addresses in Office 365
- Find the email address for user mailboxes
- Export shared mailboxes’ email addresses
- View distribution groups’ email addresses
- Find email addresses of the guest user
- Show email addresses of mail contacts
- List group mailboxes and their email addresses
- Export dynamic distribution group email address
To view all the Primary email addresses and alias used in your organization, run the script as follows.
User mailboxes are associated with people. To view all the user mailboxes and their primary and proxy addresses, you can run the script with –UserMailboxOnly Param.
A shared mailbox is a kind of user mailbox that doesn’t have a user name and password. Based on the permission given, users can access the shared mailbox. To find shared mailbox alias, run the script with –SharedMailboxOnly parameter.
Distribution lists are used to send emails and notifications to groups of people for communication and collaboration purposes. You can list all the distribution groups and their SMTP and alias addresses by using the format below.
In the Office 365 environment, guest users can be added through Azure Active Directory, SharePoint, Microsoft Teams, etc. To list all the guest users and the associated email addresses, execute the script with –GuestOnly param as shown below.
Mail contacts are for people who exist outside your organization. Each mail contact has an external email address. To get a list of mail contacts with their external email address, run as follows.
Group mailboxes are Microsoft 365 groups that are used for collaboration with both internal and external users. It includes services like SharePoint, Teams, Planner, etc. To get all the Office 365 groups and their email alias, you can execute the script with –GroupMailboxOnly param.
Dynamic distribution groups are mail-enabled groups that send mass emails based on their dynamic membership. The group membership is determined by the AD property that matches the group condition. To view dynamic distribution groups’ email addresses, run the script as shown below.
Ugh! At last, we’ve done scripting for various use cases of getting Microsoft 365 email addresses. Admins no longer need to dive deep into the EXO PowerShell Ocean🌊 – AdminDroid brings all your desired pearls right to your fingertips. Let’s see how it brings them easily to you.
AdminDroid Exchange Online mailbox reports serve you with all the above use cases without the need for PS scripting. The in-depth insights and powerful charts📈 make AdminDroid a leading light among other reporting tools. It solves all the above use cases and provides every bit of detail with advanced features like exporting into CSV and other formats, scheduling📅, alerting, filtering, and more. With the Exchange Online reporting tool in hand, you will get all your desired pearls! Let’s see the key reports below.
- All Office 365 mailboxes
- All Office 365 user mailboxes
- All shared mailboxes
- Dynamic distribution groups
- Distribution groups
- All Office 365 contacts, etc.
In addition, it provides mailbox permission reports, mailbox settings, mailbox devices, mailbox usage, and more. With all these plentiful reports and countless features in AdminDroid, your Exchange Online management becomes a piece of cake. Enhance your management experience with AdminDroid like never before.
I hope this blog will help you get all Office 365 email addresses, and you can change the email address if required. Also, you can add or remove alias based on the business needs.