Export and display information about Email addresses using PowerShell | Office 365 | Part 6#13 5/5 (3) 11 min read

In this article, we review that basic PowerShell command syntax that we use for display information about the E-mail addresses of Exchange Online recipients.

In addition, we review the PowerShell command syntax that we use in case that we need to export the PowerShell command output the various type files such as – TXT, CSV, HTML and XML.


The structure of the PowerShell command that we use for Get information about E-mail addresses

The structure of the PowerShell command that we use for display information about E-mail address is implemented as follows:

1. The specific recipient type

We use the PowerShell cmdlet prefix “Get” and specify the specific Exchange Online recipient type that we want to address. In the article – Introduction to the various type of Exchange Online recipients | PowerShell cmdlets | Office 365 | Part 8#13 , we will be able to be impressed by the variety of the Exchange Online recipient. For now, let’s briefly say that we can specify a specific type of recipient such as “Mailbox recipient”, “Group recipient” and so on or, we can use a PowerShell cmdlets such
as – Get-Recipient that relate to most of the existing Exchange Online recipient’s types.

2. The recipient “standard” property that we want to display

Most of the time, we want to selective “tell” PowerShell, what is the specific object (recipient) properties that we want to view.

The definition of the properties can be “standard recipient properties” (number2):

  1. “Identity properties” such as DisplayName or Alias
  2. Recipient properties that “store” E-mail address information such as EmailAddresses or, PrimarySmtpAddress.

At the same time, PowerShell enables us to create a “custom properties” (number 3) that include the name that we define for the specific property and a “calculated output” such as – a result of a query, some calculations, and so on.

We will review this method in the Article – Adding Email addresses using PowerShell – Import from CSV file | Bulk mode | Office 365 | Part 5#13

Using the “output” of the PowerShell command – information about E-mail addresses

The “output” that we get from the PowerShell command that “get for us” information about the E-mail addresses of Exchange recipients, can be:

  • Displayed on the PowerShell console.
  • Stored in a variable.
  • Exported to various file types such as – TXT,CSV,XML and HTML.

In the following diagram, we can see the structure of the PowerShell command that we use for displaying information about “E-mail addresses” and optionally, export the information to a file.

The structure of the PowerShell command that we use for get information about E-mail addresses

E-mail address properties | The “E-mail address store”

The “main store” that serve as a “logical container” for all the types of E-mail addresses in Exchange Online environments is – a field named – “EmailAddresses”.

Note – In Office 365 and Exchange Online environment there are additional “email property” fields. For example, Exchange Online uses the following properties – WindowsEmailAddress and PrimarySmtpAddress for storing information about the primary E-mail address.

Exchange Online recipient – various type of E-mail addresses

Each Office 365 recipient, can have multiple E-mail address that includes:

  1. Smtp E-mail address (primary E-mail address and Proxy E-mail address.
  2. x500 E-mail address.
  3. Non-smtp E-mail address” such as – SIP address, that is used as user identity when using the Skype for business services.

The Exchange Online container of E-mail addresses - EmailAddresses-01


Viewing information about E-mail addresses on the PowerShell console

Display E-mail address information using PowerShell console

The “default” PowerShell command syntax that we use for – display information about a recipient E-mail address is quite simple.

We need to specify:

  • The specific type of recipient such as “mailbox recipient”.
  • The identity of Exchange Online recipient (Alias or E-mail address etc.)
  • The specific properties that we want to display such as – DisplayName, PrimarySmtpAddress, EmailAddresses.

PowerShell command syntax

PowerShell command example

In the following screenshot, we can see the result (the “EmailAddresses” property content).

The information that stored in the “EmailAddresses” field, include information about all the
existing E-mail address, and “other address” that the recipient has such x500 E-mail address and SIP address.

The Exchange Online container of E-mail addresses - EmailAddresses-02

Display information about Primary E-mail address

In case that we need to display information only about the Primary E-mail address of specific Exchange Online recipient, we can use the following syntax:

PowerShell command example

To display information about all Exchange Online mailboxes Primary E-mail address, we can use the following PowerShell command syntax:

PowerShell command example

The “limitation” of the PowerShell console regarding the subject of E-mail addresses

Although we can use the PowerShell console for displaying information about Exchange Online
recipient’s E-mail addresses, working with the PowerShell console, is not so comfortable because of built-in limitations.

For example, in case that a specific recipient has multiple E-mail addresses, the PowerShell console, is not able by default to display all the E-mail addresses.

Instead, the PowerShell console displays a limit number of E-mail addresses and use the three dots characters (…).

The purpose of the three dots characters (…) is to “tell” us, that there are additional E-mail addresses that cannot be displayed.

Expend the “E-mail address property”

Regarding the “issue” of displaying the “Full content” the multiple value recipient E-mail property, we can implement a “partial solution” for a specific recipient for the issue of displaying multiple E-mail addresses, but this solution is not Properly implemented in a scenario in which we need to display information about multiple recipients

In the following example, we use a PowerShell command that gets information about
Angelina E-mail addresses.

PowerShell command example

In the output, we can see that the “EmailAddresses” property includes many E-mail addresses.


Export information about a recipient E-mail addresses

One of the most common administrative tasks that relate to Exchange recipients is the need to view, and export information about the recipient E-mail address.
In many scenarios, we will need to “save” the information about the recipient E-mail address for later use by exporting the information to a file.

In the former articles, we review the PowerShell command with the “Set prefix” such as Set-Mailbox that was used to update the Exchange recipient email address.

To be able to get information about specific property of the Exchange Online recipient, such as the recipient E-mail address, we use the PowerShell command with the “Get prefix” such as Get-Mailbox.

The PowerShell command Get-Mailbox, display the output on the PowerShell console, and in case that we need to export the information, we add additional “part” to the PowerShell command, with instructions about the file type that we want to use.

Export to file using PowerShell and supported file formats.

PowerShell supports the option of exporting command output to the following file formats: Text, CSV, HTML, and XML.

When we want to export the “command output” to a File, we need to “tell” PowerShell what is the required file format that we want to use.

In addition to the PowerShell cmdlets that we use to define the specific file format, we can “add” specific parameter that relates to the specific file format.

For example, when we wish to export PowerShell command output to a CSV (Comma Separated Value) file format, we can add additional parameters such as:

  • –NoTypeInformation – this option prevents from PowerShell to add unnecessary information to the CSV file.
  • -Encoding UTF8 – in case that the objects such as users, or mailboxes include non-English characters, we can add this “format parameter” to enable PowerShell export information that includes non-English characters.

The File name and the “path” parameter

A mandatory requirement when export command output to a file is the “File name.

The additional part is the “Path.” The “path” parameter defines the specific location in which we want to save the file. For example – C:\Temp.

The “path” parameter is not a mandatory parameter. Most of the times, when we export information to a file, we will also provide the “path” information.

In case that we don’t provide a specific path, PowerShell exports the file to the folder from which we run the PowerShell command.

It’s important to mention that when we provide the name of a specific path, such as C:\Temp, the PowerShell command “except” that this path is already created.

In other words, by default, the PowerShell command will not “create for us” a specific folder that was specified in the “path” parameter.

Example of PowerShell syntax for exporting information to various file types

The following section, include an example of PowerShell command syntax that we use for exporting information about the E-mail addresses of Exchange Online mailbox recipients using the four file formats.

To export command syntax is built from two parts:

  • Part 1#2 – this is the part of the “Get PowerShell cmdlets”, that fetch a specific information.
  • Part 2#2 – this is the part in which we define the specific file format, the path, and the filename.

In the following section, we can see an example of the “export syntax” for four file formats – TXT,CSV,XML and HTML.

Export PowerShell command output to a Text file.

Export PowerShell command output to a CSV file.

Export PowerShell command output to an HTML file.

Export PowerShell command output to a XML file.


Managing E-mail Addresses | PowerShell scripts series

The subject of “Managing E-mail addresses” in an Exchange environment, can be translated into various administrative tasks such as – Bulk Adding Alias E-mail address to multiple Exchange Online mailboxes, Bulk Removing Alias E-mail address from multiple Exchange Online mailboxes, backup existing E-mail address, replace primary E-mail address and so on.
To be able to accomplish these various tasks, I have created seven PowerShell menu scripts, that will help you in performing these tasks.

Export Email addresses | Exchange Online | Using PowerShell | 1#7

A PowerShell menu script, that will help you to:
Create a report (that will be exported to files) about – All Exchange Online recipients and their different type of E-mail address such as SMTP E-mail address (Primer E-mail address and Alias E-mail address), SIP address, X.500 E-mail address, etc.

You can read more detailed information about the PowerShell commands that are used in the script in the articles:

Export and display information about Email addresses using PowerShell - Office 365 - Part 6-13


Search Email Addresses + export | Exchange Online | Using PowerShell | 2#7

A PowerShell menu script that will help you to:
Perform a search for a specific E-mail address or, for an E-mail address that uses a specific Domain name suffix of Exchange Online recipients, and exports the information to files.

In case that you want to get more detailed information about the subject of – locating specific E-mail addresses, you can read the articles:

Searching hidden Email addresses Using PowerShell - Office 365 - Part 11-13


Bulk Add Alias E-mail address – Specific Domain name suffix | 3#7

A PowerShell menu script that will help you to:
TEST + implement the process of – Bulk add additional Alias E-mail addresses with a specific Domain name suffix, to multiple Exchange Online mailboxes.

Additional information

In case that you want to get more detailed information about the subject of – adding additional Alias E-mail address, you can read the articles:

Adding Email addresses using PowerShell - Bulk mode - Office 365 - Part 4-13


Add Additional Proxy (Alias) E-mail address | import from a CSV | 4#7

A PowerShell menu script that will help you to:
TEST + implement the process of – Bulk add an additional Proxy (Alias) E-mail addresses to the Exchange Online recipient, that are imported from a CSV file.

Additional information

In case that you want to get more detailed information about the subject of – Add additional Alias E-mail by importing the information from a CSV file, you can read the articles:

Adding Email addresses using PowerShell - Office 365 - Part 3-13


Bulk Remove Alias E-mail address – Specific Domain name suffix | 5#7

A PowerShell menu script that will help you to:
TEST + implement the process of – Bulk deleting existing Alias E-mail addresses with a specific Domain name suffix from multiple Exchange Online mailboxes.

Additional information

In case that you want to get more detailed information about the subject of – removing (deleting) E-mail address with a specific domain name suffix, you can read the article   Remove Email addresses using PowerShell | Office 365 | Part 12#130
Remove Email addresses using PowerShell - Office 365 - Part 12-13


Assign NEW Primary E-mail address using a specific Domain name suffix | 6#7

A PowerShell menu script that will help you to:
TEST + implement the process of – Bulk replacing (remove) existing primary E-mail addresses, with a NEW Primary E-mail address that has a specific Domain name suffix.

Additional information

In case that you want to get more detailed information about the subject of – replacing Primary E-mail address, you can read the article – Adding Email addresses using PowerShell | Office 365 | Part 3#13

Adding Email addresses using PowerShell - Bulk mode - Office 365 - Part 4-13


Manage E-mail addresses – Single mailbox | Exchange Online | 7#7

A PowerShell menu script that will help you to:
Manage E-mail address of a specific Exchange Online mailbox (add Alias, delete Alias, replace primary E-mail address).
Adding Email addresses using PowerShell - Office 365 - Part 3-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

Summary
Export and display information about Email addresses using PowerShell | Office 365 | Part 6#13
Article Name
Export and display information about Email addresses using PowerShell | Office 365 | Part 6#13
Description
In this article, we review that basic PowerShell command syntax that we use for display information about the E-mail addresses of Exchange Online recipients. In addition, we review the PowerShell command syntax that we use in case that we need to export the PowerShell command output the various type files such as – TXT, CSV, HTML and XML.
Author
Publisher Name
o365info.com
Publisher Logo

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 *