When dealing with multiple customers and Exchange installations it could be impractical, if not impossible, to have Exchange Management tools installed on your workstation (I’m leaving out the domain join part on purpose), in the past you had to be creative to manage Exchange remotely but luckily this has changed with recent releases of the product.
Specifically with Exchange 2013 Admin Center it became easier to access the Web based administration page to perform various admin tasks but, if like me, you prefer using PowerShell to get the job done please continue reading!
In this post I will concentrate on Remote PowerShell sessions as a method to manage Exchange remotely but in a future post I will show how to use PowerShell ISE so to save sessions to ISE GUI so to quickly connect to the desired environment with minimal effort.
Manage Exchange Remotely – Remote PowerShell
Since Exchange 2010 whenever you run the Exchange Management Shell, even from the local server, you are establishing a remote PowerShell session to the Exchange server, knowing this it is easy to guess how it’s possible to use the same mechanism from a remote workstation/machine, before you can remotely connect to there are some pre-requisites that need to be satisfied which are listed below:
- Microsoft .NET Framework 4.5 must be installed on the computer you will use to connect to the Exchange server
- Windows Management Framework 3.0 must be installed on the computer you will use to connect to the Exchange server
- TCP port 80 must be open between your client computer and the remote Exchange server
- The user account you use to connect to the remote Exchange server must be enabled for remote Shell
- The user account must be a member of a management role group or be directly assigned a management role that enables the user to run Exchange cmdlets
- Windows PowerShell script execution must be enabled on the computer you want to use to connect to an Exchange server (RemoteSigned is enough)
Manage Exchange Remotely – Enable user for remote Shell
As illustrated in the previous paragraph before you will be able to connect to Exchange via remote PowerShell session you’ll need to grant proper permission which can be easily done through the following command:
Set-User Lethe -RemotePowerShellEnabled $True
Manage Exchange Remotely – Remote PowerShell Session
Once you have granted all required permissions you can connect to the remote Exchange server with the following set of commands, here I am assuming the computer from which you are connect is not joined to the same domain as the Exchange server:
# Store credentials to be used for connection $exUser = Get-Credential
You will be prompted for a username and a password once we have this stored we can proceed with connecting to the server with the following command:
# Configure Session to the Exchange Server $exSession= New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange Client Access server>/PowerShell/ -Authentication Kerberos -Credential $exUser
The final step would be importing the server side session into the client side session with the following command:
Some text will scroll by and finally the session will be imported on the client side PowerShell session making available cmdlets which can be used to manage Exchange remotely and are not part of the standard PowerShell library, the image below comes from my lab where I’ve connected to one of the Exchange 2013 servers that I am running:
If you are connecting to the remote Exchange server from a workstation which is joined to the same domain you can even skip the Get-Credential cmdlet and just use the following command for the connection:
$exSession= New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange Client Access server>/PowerShell/ -Authentication Kerberos Import-PSSession $exSession
The above command will automatically use credentials of the currently logged on user to connect to the Exchange server.