How to use the PowerShell script – manage Email addresses in Office 365 | Part 13#13 5/5 (1) 8 min read

In the current article, I would like to provide a basic review of the PowerShell script that I created that will help you to implement various tasks that relate to E-mail address management in Office 365 and Exchange Online based environment.

The stature of the – “Manage E-mail addresses menu based PowerShell script”

In the following screenshot, we can see the structure of the “Manage E-mail address” PowerShell script.

To be able to use each of the PowerShell script menu options you will need to start by connecting to Exchange Online.

Part A – using menu option 1, will initialize the remote PowerShell connection to Exchange Online and you will need to provide your Global administrator credentials.

Part B – this part includes all the menu option that relates to Exchange Online information and the various management tasks. In the next section, you can read more information about specific menu option.

Part C, D – this part relates to Azure Active Directory infrastructure. In case that we need to export information about Azure Active Directory infrastructure users, we will need to create a separated PowerShell session (using menu 11).

Part E – include a menu option that will help you to exit from the PowerShell script menu or disconnect the remote PowerShell session.

The structure of the o365info.com PowerShell menu based script

Note – If you need more instructions about how to run PowerShell script, you can read the article – How to run and use the o365info PowerShell menu script

Connect to Exchange Online and Office 365 using Remote PowerShell

The PowerShell script includes two separated menus that will help you to create the remote PowerShell session too

  1. Exchange Online
  2. Office 365 (Azure Active Directory)

Menu 1 – Login to Office 365 + Exchange Online using Remote PowerShell

This is the menu that will help to create the remote PowerShell session to Exchange Online.

Initialize the Remote PowerShell session to Exchange Online-01

Menu 10 – Connect to Office 365 (Azure Active Directory) using Remote PowerShell

In case that you need to connect to Office 365 (Azure Active Directory), you can use menu number “10”.

To be able to create a remote PowerShell session, you will need to install two software components.

  1. Install the 64-bit version of the Microsoft Online Services Sign-in Assistant:Microsoft Online Services Sign-in Assistant for IT Professionals RTW.
  2. Install the 64-bit version of the Windows Azure Active Directory Module for Windows PowerShell:Windows Azure Active Directory Module for Windows PowerShell (64-bit version).

Initialize the Remote PowerShell session to Azure Active Directory -02

Exporting information to various file types

Many of the menu options, export information about Exchange Online recipients and Azure Active Directory users to files.

The exported information is implemented by using three different file types:

  1. TEXT
  2. CSV
  3. HTML

CSV file

When the information stored in a CSV file format, we can use an application such as – Microsoft Excel, that provides many tools for “manipulating” the data stored in the CSV file.
For example, format the information as a Table, sort data in a specific column, filter a specific column and so on.

In the following screenshot, we can see an example to the way that we can edit CSV file content using Microsoft Excel. The data in the CSV file were formatted as a “table” and each table column includes “sort” options and “filter” options.

PowerShell Exporting information to File – CSV file format -02

HTML format

The HTML format is used most of the time for creating “Reports”.

The information in the HTML cannot be “manipulated” as the information stored in a CSV file, but, the presentation is more “easy to read”.

The PowerShell script that I created using additional HTML staying beyond the “stranded” PowerShell HTML output.

In the following screenshot, we can see an example of an HTML report that the PowerShell script creates.

PowerShell Exporting information to File – HTML file format -03

Menu 2 – Export information about – Exchange Online recipients grouped by recipient type

When using this option, the script will execute the following tasks:

  1. Display information about the number of Exchange Online recipient by recipient type.
  2. Export the information to files.

Menu 3 - Export information about - Exchange Online recipients grouped by recipient type --01

In the following screenshot, we can see the results

The files are exported to the following path – C:\INFO\Exchange Online recipients- <Date>

The script creates a dedicated folder for each type of Exchange Online recipient, such as User mailbox, groups and so on.

Menu 3 - Export information about - Exchange Online recipients grouped by recipient type -02

The information about the specific Exchange Online recipient type such as – “user mailbox recipient” is exported using three file formats: Text, CSV, and HTML.

Menu 3 - Export information about - Exchange Online recipients grouped by recipient type -03

Menu 3 – Export information about – Various type of E-mail addresses | All Exchange Online recipients

The purpose of this menu is to provide a report about “ALL” of the Exchange Online recipients.

A quick reminder:

The Exchange Online PowerShell cmdlet –Get-Recipient “get” information about all Exchange Online recipients besides – Unified groups, and Soft Deleted Exchange Online mailboxes.

For this reason, the “Full report” include three reports that will cover all of the available Exchange Online recipients.

Menu 3 - Export information - Various type of E-mail addresses - All Exchange Online recipients-01

In the following screenshot, we can see the result of the CSV report that was created by using the PowerShell command – Get-Recipient.

Number 1 – Primary E-mail address
This column, includes information about the recipient Primary E-mail address.

Number 2 – proxy E-mail address separated
This column, includes information about the recipient Proxy E-mail address separated by the “;” characters.

By default, PowerShell export the information about the Proxy E-mail address without a “separation character. The default PowerShell output will export the information about Proxy E-mail address separated by a “space”.

In some scenario, when we need to import the information from the CSV file or implement another type of “data manipulation”, the application that edits the data such as Microsoft Excel, need the “separation characters”.

In additional, I have “remove” the “smtp:” prefix from the results.

Number 3 – proxy E-mail address
This column includes the “standard” PowerShell output of Proxy E-mail address (without a separation character and with the “smtp:” prefix).

Menu 3 - Export information - Various type of E-mail addresses - All Exchange Online recipients-02

You can read more information about the way that we use to “manipulate” the output results in the next Article

In the following screenshot, we can see the “rest” of the E-mail address that appear in the file such as: SIP address (number 4), x500 address (number 5).

In addition, the file includes information about the specific classification of the recipient, such as Mailbox user, group and so on (number 7,8).

Menu 3 - Export information - Various type of E-mail addresses - All Exchange Online recipients-03

Menu 4 – Export information about – recipient that was synchronized from Exchange on-Premises

This option will export information about the Exchange Online recipient that are “Exchange on-Premises recipients” that synchronized to the “cloud”.

You can read more information about the filter that we use in the article – xxx

Menu 5 – Search for a Specific E-mail address

Using this menu, we can perform a search for a specific E-mail address.

In phase 1, we need to provide the E-mail address that we look for.

Menu 5 - Search for a Specific E-mail address -01

In the following screenshot, we can see the result- Bob is a “user recipient”.

Menu 5 - Search for a Specific E-mail address -02

You can read more information aboutThis subject in the next Article

Menu 6 – Search for an E-mail addresses with a specific Domain name suffix – Export results to a File

The purpose of this menu is to enable us to locate all the Exchange Online recipient that they’re
E-mail address include a specific domain name suffix.

You will need to provide the domain name suffix you look for and the PowerShell command will export the information to three file types (TXT, CSV and HTML) that will be stored in the following path C:\INFO\Exchange Online recipients with specific E-mail address

You can read more information aboutThis subject in the next Article

Menu 7 – Add additional E-mail address (Alias) using a NEW Domain name to all recipients (Bulk Mode)

Using this option will enable us to perform a “bulk operation” off – adding an E-mail address with a specific domain name suffix for each of the Exchange Online recipients defined as “Mailbox recipients”. For example – user mailbox, Shared mailbox etc.

The PowerShell script will use the command –Get-Mailbox -ResultSize Unlimited.

In case that you want to understand better the “logic” of the bulk task, read the articles:

Menu 10 – Export information about – Azure Active Directory user, groups and contacts

Connecting Exchange Online and Azure Active Directory via remote PowerShell


For your convenience, I have “Wrapped” all the PowerShell commands that were reviewed in the article,
in a “Menu Based” PowerShell Script.

You are welcome to download the PowerShell script and use it.
Download -o365info PowerShell Script

Manage E-mail address using PowerShell script
In case that you need instructions about – how to use the Manage E-mail address PowerShell script menu, you can read the fowling Article.

The former article in the current article series

Remove Email addresses using PowerShell | Office 365 | Part 12#13

Now it’s Your Turn!
It is important for us to know your opinion on this article

Restore Exchange Online mailbox | Article series index

Print Friendly, PDF & Email

Related Post

Please rate this

Eyal Doron on EmailEyal Doron on FacebookEyal Doron on GoogleEyal Doron on LinkedinEyal Doron on PinterestEyal Doron on RssEyal Doron on TwitterEyal Doron on WordpressEyal Doron on Youtube
Eyal Doron
Share your knowledge.
It’s a way to achieve immortality.
Dalai Lama

Leave a Reply

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