Connect to Exchange servers using remote PowerShell
Applies to: Exchange Server 2016
Use Windows PowerShell on a local computer to connect to Exchange Server 2016.
If you don't have the Exchange management tools installed, you can use Windows PowerShell on your local computer to create a remote PowerShell session to an Exchange 2016 server. It’s a simple three-step process, where you enter your credentials, provide the required connection settings, and then import the Exchange cmdlets into your local Windows PowerShell session so that you can use them.
We recommend that you use the Exchange Management Shell on any computer that you use to extensively administer Exchange 2016 servers. You get the Exchange Management Shell by installing the Exchange management tools. For more information, see Install the Exchange 2016 management tools and Open the Exchange Management Shell.|
For more information about the Exchange Management Shell, see Using PowerShell with Exchange 2016 (Exchange Management Shell).
Estimated time to complete: less than 5 minutes
You can use the following versions of Windows:
Windows Server 2012 R2*
Windows Server 2012**
* You need to install the Microsoft .NET Framework 4.5.2 or later. For more information, see Installing the .NET Framework.
** After you install the .NET Framework 4.5.2 or later, you also need to install the Windows Management Framework 4.0. For more information, see Windows Management Framework 4.0.
Windows PowerShell needs to be configured to run scripts, and by default, it isn't. You get the following error when you try to connect:
Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files.
To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you open by selecting Run as administrator):
You need to configure this setting only once on your computer, not every time you connect.
For information about keyboard shortcuts that may apply to the procedures in this topic, see Keyboard shortcuts in the Exchange admin center.
On your local computer, open Windows PowerShell, and run the following command:
$UserCredential = Get-Credential
In the Windows PowerShell Credential Request dialog box, type your user name and password, and then click OK.
Run the following command. You need to specify the fully qualified domain name (FQDN) of the Exchange 2016 Mailbox server that you want to connect to, for example,
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2016 Mailbox server>/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Run the following command:
|Be sure to disconnect the remote PowerShell session when you're finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire. To disconnect the remote PowerShell session, run the following command:|
After Step 3, the Exchange cmdlets are imported into your local Windows PowerShell session and tracked by a progress bar. If you don’t receive any errors, you connected successfully. A quick test is to run an Exchange cmdlet, for example, Get-Mailbox, and review the results.
If you receive errors, check the following requirements:
A common problem is an incorrect password. Run the three steps again, and pay close attention to the user name and password you enter in Step 1.
The account you use to connect to the Exchange server needs to be enabled for remote PowerShell access. For more information, see Control users' access to remote PowerShell.
TCP port 80 traffic needs to be open between your local computer and the Exchange server. It's probably open, but it’s something to consider if your organization has a restrictive network access policy.