- 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.
- 極簡算法史:從數(shù)學(xué)到機(jī)器的故事
- C# Programming Cookbook
- Hands-On Image Processing with Python
- SQL for Data Analytics
- INSTANT CakePHP Starter
- Java虛擬機(jī)字節(jié)碼:從入門到實(shí)戰(zhàn)
- Mastering LibGDX Game Development
- 快人一步:系統(tǒng)性能提高之道
- R Data Analysis Cookbook(Second Edition)
- Kotlin編程實(shí)戰(zhàn):創(chuàng)建優(yōu)雅、富于表現(xiàn)力和高性能的JVM與Android應(yīng)用程序
- Python深度學(xué)習(xí)原理、算法與案例
- Unity 5.X從入門到精通
- Python預(yù)測(cè)分析與機(jī)器學(xué)習(xí)
- 企業(yè)級(jí)Java現(xiàn)代化:寫給開發(fā)者的云原生簡明指南
- 軟技能2:軟件開發(fā)者職業(yè)生涯指南