- Microsoft Exchange Server PowerShell Essentials
- Biswanath Banerjee
- 555字
- 2021-07-16 13:05:00
Connecting from Remote computers
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:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2013/2016 ClientAccess server>/PowerShell/ -Authentication Kerberos -Credential $Credential
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:
$Credential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session
Troubleshooting Remote PowerShell session connectivity
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, useSet-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.
- Visual C++程序設(shè)計(jì)學(xué)習(xí)筆記
- Vue.js 2 and Bootstrap 4 Web Development
- 少年輕松趣編程:用Scratch創(chuàng)作自己的小游戲
- 數(shù)據(jù)庫(kù)系統(tǒng)原理及MySQL應(yīng)用教程
- Neo4j Essentials
- HTML5游戲開(kāi)發(fā)案例教程
- MATLAB定量決策五大類問(wèn)題
- Getting Started with Python Data Analysis
- 精通Python設(shè)計(jì)模式(第2版)
- 從零開(kāi)始學(xué)Linux編程
- Android驅(qū)動(dòng)開(kāi)發(fā)權(quán)威指南
- Spring MVC+MyBatis開(kāi)發(fā)從入門(mén)到項(xiàng)目實(shí)踐(超值版)
- Learning Grunt
- UML基礎(chǔ)與Rose建模實(shí)用教程(第三版)
- Xamarin Cross-Platform Development Cookbook