官术网_书友最值得收藏!

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, 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.
主站蜘蛛池模板: 乌兰浩特市| 齐齐哈尔市| 桃源县| 宝山区| 榆树市| 永定县| 鸡西市| 商都县| 红桥区| 柞水县| 金川县| 犍为县| 靖安县| 依安县| 台中市| 嘉祥县| 弥勒县| 广水市| 峡江县| 商洛市| 潍坊市| 奈曼旗| 桃江县| 伊吾县| 镇江市| 广元市| 满洲里市| 奉节县| 舟曲县| 通榆县| 南安市| 阳高县| 奉化市| 屏南县| 通化县| 龙江县| 崇义县| 隆子县| 庆城县| 格尔木市| 盱眙县|