Get All Office 365 Email Address and Alias Using PowerShell 

Get All Office 365 Email Address and Alias Using PowerShell

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 Highlights:

  • 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.

Export Microsoft 365 Email Addresses – Sample Output:

The exported report contains following attributes: Display Name, Recipient Type Detail, Primary SMTP Address, Alias Email Address.

Get all Office 365 email addresses

Script Execution Steps:

To run the script, you can choose any one of the methods below.

Method 1: Execute the script with MFA and non-MFA accounts

.\GetAllOffice365EmailAddresses.ps1 

Method 2: Execute the script by explicitly mentioning the credentials.

.\GetAllOffice365EmailAddresses.ps1 -UserName [email protected] -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.

More Use-cases of ‘Get All Office 365 Email Address’ PowerShell Script:

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 Address in Office 365:

To view all the primary email addresses, including any additional email addresses, run the script as follows.

.\GetAllOffice365EmailAddresses.ps1  

After getting the alias address of all mailboxes, you can also convert the alias address to the primary SMTP address for specific mailbox or bulk mailboxes based on your requirements.

Find User Mailboxes and Their SMTP Address:

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.

.\GetAllOffice365EmailAddresses.ps1 -UserMailboxOnly  

With proxy addresses, you can send emails from different email addresses without needing to switch accounts.

Export Shared Mailboxes’ Email Addresses

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.

.\GetAllOffice365EmailAddresses.ps1 -SharedMailboxOnly 

View Distribution Lists and Their Email Addresses:

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.

.\GetAllOffice365EmailAddresses.ps1 -DistributionGroupOnly  

Find Guest Users’ Email Addresses:

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.

.\GetAllOffice365EmailAddresses.ps1 -GuestOnly  

List Mail Contacts and Their Email Address:

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.

.\GetAllOffice365EmailAddresses.ps1 -ContactOnly 

View Email Address of the Group Mailboxes:

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.

.\GetAllOffice365EmailAddresses.ps1 -GroupMailboxOnly  

Get Dynamic Distribution Group Email Addresses:

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.

.\GetAllOffice365EmailAddresses.ps1 -DynamicDistributionGroupOnly  

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.

How AdminDroid Downsize your EXO PowerShell Challenges?

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.

Microsoft 365 User Mailboxes

Microsoft 365 Shared Mailboxes

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.

Get All Office 365 Email Address and Alias Using PowerShell 

by Kathy time to read: 4 min
0