Managing Exchange Server 2016 Using PowerShell

Posted by Nicolas Prigent on March 1, 2017
Share on Facebook0Share on Google+0Share on LinkedIn7Share on Reddit14Tweet about this on Twitter0
5/5 (5)

Exchange Server 2016 Using PowerShell

PowerShell has become the preferred tool for managing Microsoft server products. Sysadmins can take full advantage of PowerShell to manage roles and perform routine management tasks. By using the command line, sysadmins are able to:

  • Create a mailbox
  • Configure a receive connector
  • Generate a custom report
  • Manage Distribution Group members, permissions, and group types
  • Manage Exchange Services
  • Etc.

In this article, we will not cover all the Exchange Management cmdlets but I will describe several examples to guide you in the right direction. In all Exchange Server edition, a lot of settings are configured automatically by the Exchange installation. So it is a good idea to explore all the settings individually to become familiar with your Exchange Server.

Exchange Management Shell

Thanks to the previous article, you have everything installed. Now it’s time to configure your Exchange server using the Exchange Management Shell console. What is it? EMS (Exchange Management Shell) is based on Microsoft Windows PowerShell, which provides a powerful command-line interface for executing and automating administrative tasks. With the Exchange Management Shell, you can manage every aspect of Exchange Server 2016.

How to run the Exchange Management Shell?

Let’s take a look at a couple of ways that you can use the EMS in a scripting environment. When you install an Exchange Server, you get the Exchange tools installed along with it which give you the EMS.

Exchange tools in the Exchange Server

Click Start > Microsoft Exchange Server 2016 > Exchange Management Shell.

Exchange Management Shell

As you can see, it is just a customized version of “powershell.exe” that will load the Exchange PowerShell module. You may want to connect manually to your Exchange server from the PowerShell console. So, let’s start by creating a PowerShell Session:

You need to manually specify the server you want to connect to. Next, you should be able to use the Import-PSSession cmdlet to load the Exchange module:

Import-PSSession cmdlet to load the Exchange module

Now, you can compare both consoles, by running the Get-Mailbox cmdlet to list all the mailboxes on your Exchange Server and confirm that the result is the same:

Get-Mailbox cmdlet

Which one do you have to use? Well, it’s up to you!

Checking the Microsoft Exchange Server Status

Before configuring Exchange, we will just check that Exchange Services are started:

Microsoft Exchange Server Status

I don’t want to use IMAP and POP, so these Windows Services are stopped. Now, we can check some useful information about our Exchange Server:

cmdlet for Exchange Server

How to know which cmdlets are available to configure Exchange?

When you open the console, EMS shows you some useful tips. So you can run this command to display only Exchange cmdlets:

Exchange cmdlets

You can get the full list on the TechNet website:

Configuring Exchange Server 2016

Now, we can start by configuring accepted domains and email address policies. Accepted domains are the SMTP name spaces that you configure to receive email messages. To create an accepted domain, use the following command:


command for configutring accepted domain

We can verify that we have successfully created an accepted domain and make it as the default domain.

checking accepted domain

Use the New-EmailAddressPolicy cmdlet to create e-mail address policies:

Exchange requires you to use variables to define the local part of the email address. These variables are described in the following table (from the TechNet website):

variables to define the local part of the email address

Get email adress policy command


You must create a send connector to route outbound mail to internet. I advise you to route outbound mail through a smart host (Antispam Gateway).

This connector will send email messages over the Internet. The -FrontendProxyEnabled parameter is set to True. This means that Exchange will actually proxy outbound emails through the CAS server to the internet.

New Send Connector command

Please note the following information:

  • Exchange does not automatically create a default send connector
  • A basic connector will send out to the Internet via DNS resolution

Note that if you want to test SMTP connectors on Exchange, you can run the following command:

Exchange Server 2016 use receive connectors to control Inbound SMTP connections from messaging servers that are external to your Exchange Organization. Exchange creates a default receive connector:

Get Receive Connector command

But if you need to create a new one, use the following:

Monitoring Exchange Server

How to check the content of an email queue?

it is good to know how to check an email queue. This is useful to determine if the mail flow is fluent or not. There are three types of queues available on Exchange Servers:

  • Submission: Messages waiting to be processed by transport agents
  • Unreachable: Messages that could not be delivered to their destination
  • Poison message: Messages classified as dangerous for the server.

To check the contents of the submission queue run the following command:

Get Queu Identify Submission command

Exchange Server has some useful logs that you can check. Use the Get-MessageTrackingLog cmdlet to search for message delivery information stored in the message tracking log.

You can also count the total email messages processes by Exchange Server:

Get message tracking log command

Some months ago, I wrote two PowerShell scripts. The first one let you perform a query in the message tracking log from a GUI. This script is available on the Microsoft TechNet Gallery:

Message tracking log gui

And the second one is a health check for your Exchange environment:

Mailbox and Distribution Group Management

There are different types of the recipient in Exchange Server 2016. After installing Exchange 2016, you can create user mailboxes which is one of the most commonly used mailbox types. But you can also create resource mailboxes and distribution groups. Let’s see some examples:

Create user mailbox

Read host command

Create resource mailbox

Create resource mailbox command

Create equipment mailbox

Create equipment mailbox command

Create distribution group

Create distribution group command

Remember that for a New-* cmdlet, there are often (but not always) Get-* and Set-* cmdlets available.

Managing Outlook/OWA Configuration

Finally, most of Outlook’s Exchange specific functionalities such as Automatic Replies (also known as “Out of Office Assistant” or “OOF”) can also be configured using EMS. For example, Exchange Administrators can enable automatic replies for another user without logging on to the mailbox by using the Set-MailboxAutoReplyConfiguration cmdlet:


With more than 1000 cmdlets at your disposal, there is plenty that you can do with PowerShell and Exchange. I can’t cover all these cmdlets, but the idea of this article was to describe several examples and explain how PowerShell can help you in your day-to-day sysadmin tasks. Thanks to PowerShell, you can now easily create a script to deploy and configure automatically Exchange Server 2016 in a new environment.

Thanks for reading!

Related materials:

Views All Time
Views Today

Please rate this

To download the software products, please, make your choice below. An installer link and a license key will be sent to the e-mail address you’ve specified. If you consider StarWind Virtual SAN but are uncertain of the version, please check the following document Free vs. Paid. The recent build of Release Notes. A totally unrestricted NFR (Not For Resale) version of StarWind Virtual SAN is available for certain use cases. Learn more details here.

Return to all posts

Microsoft Just Released Azure Network Watcher: Network Performance Monitoring and Diagnostics Service for Azure
How to Deploy Software-Defined Networking with VMM SDN Express for SCVMM 2016?
The following two tabs change content below.
Nicolas Prigent
Nicolas Prigent
Nicolas Prigent works as a System Engineer, based in Switzerland with a primary focus on Microsoft technologies. Nicolas is Microsoft MVP in Cloud And Datacenter Management with 8 years experience in administering Windows Servers, Hyper-V and System Center products. He also received the "PowerShell Heroes 2016" Award.