In order to manage Exchange servers, you don't need to install Exchange management tools on your computer or do a remote desktop connection to the Exchange server. All you need is Windows PowerShell on your local computer through which you can connect to a remote shell session on an Exchange server.
It is important to note that in order to connect to Exchange 2013 shell remotely, you can use either Window 8 or 8.1, Windows Server 2012, or 2012 R2. For Windows 7 SP1 and Windows 208 R2 SP1 to work, you need to install the .NET Framework 4.5 with either Windows Management Framework 3.0 or 4.0.
Connecting to a remote Exchange 2013/2016 Server
The first step is to use Windows PowerShell and type the following command:
$Credential = Get-Credential
This will pop up a Credential Request dialog box, you need to type the username and password of the user who has permission to manage Exchange.
The second step is to create a variable called $Session and store the configuration information using the New-PSSession cmdlet:
The next step is to import the $Session variable and you're done. You can start managing Exchange objects and servers right from the Windows PowerShell session:
Import-PSSession $Session
After you are done with your administration, ensure that you disconnect from your session. If you close the PowerShell Window without disconnecting, you might end up in a situation where all the remote sessions available to you are used. By default, every user gets a maximum of five sessions to a remote computer, and if you have used all five, then you will not be able to connect anymore. In such a case, use Get-PSSession to get a list of sessions and remove the unwanted session using the following command:
Remove-PSSession $Session
Connecting to Exchange online
You can use the same commands with a few URL modifications to connect to Exchange online. Here are the steps for it:
Here are a few tips that will help in troubleshooting if you are not able to connect to a remote Exchange server 2013/2016 On-Premises or Exchange Online:
Check the username and password entered in the $Credential variable. A lot of time, it is due to a typing error while saving your credentials.
Check whether your computer allows scripts to run using the Get-Execution policy, and if not, set it to RemoteSigned. This is covered in the Writing a Basic Script section in Chapter 1, Getting Started with PowerShell You need to type—Set-ExecutionPolicy RemoteSigned.
Check whether the user who is trying to connect is enabled for using remote PowerShell. Run the command called Get-User <username> | FL RemotePowerShellEnabled. If the output is set to False, use Set-User to enable it and retry.
For on-premise connectivity, you need Port 80 to be opened between your computer and Exchange server as you would have noticed by now that it is an HTTP connection. This is a note for administrators who are security conscious for the On-Premise connectivity of Exchange that happens over Kerberos, which encrypts the connection, and the data is not passed in clear text over the wire.