Connect to Exchange using remote Shell


Applies to: Exchange Server 2013

If you don't have the Exchange management tools installed, you can use Windows PowerShell on your local computer to create a remote Shell session to an Exchange server. It’s a simple three-step process where you enter your Exchange credentials, provide the required connection settings, and then import the Exchange cmdlets into your local Windows PowerShell session so that you can use them.

For ease of management and to receive the benefits that come with them, we recommend that you install the Exchange management tools on any computer that's used to administer an Exchange 2013 server. For more information, see Install the Exchange 2013 management tools and Open the Shell.

For more information about the Exchange Management Shell, see Using PowerShell with Exchange 2013 (Exchange Management Shell).

Having problems? Ask for help in the Exchange forums. Visit the forums at Exchange Server, Exchange Online, or Exchange Online Protection.

  1. 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 Exchange user name and password, and then click OK.

  2. Run the following command. You need to specify the FQDN of an Exchange 2013 Client Access server.

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2013 Client Access server>/PowerShell/ -Authentication Kerberos -Credential $UserCredential
  3. Run the following command.

    Import-PSSession $Session
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.
Remove-PSSession $Session

After Step 3, the Exchange cmdlets are imported into your local Windows PowerShell session as 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 see 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.

  • Windows PowerShell needs to be configured to run scripts. You only need to configure this setting once on your computer, not every time you connect. To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell window (a Windows PowerShell window you opened by selecting Run as administrator).

    Set-ExecutionPolicy RemoteSigned
  • The account you use to connect to the Exchange server must be enabled for remote Shell. For more information, see Manage Exchange Management Shell access.

  • 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 Internet access policy.

The cmdlets that you use in this topic are Windows PowerShell cmdlets. For more information about these cmdlets, see the following topics.