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

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.
主站蜘蛛池模板: 凤凰县| 扎鲁特旗| 惠安县| 阿拉善右旗| 兴安盟| 三穗县| 台州市| 个旧市| 合水县| 双牌县| 屏边| 武清区| 马公市| 沧州市| 沧州市| 宜川县| 永靖县| 鹤庆县| 宾阳县| 柘荣县| 石楼县| 威信县| 桃江县| 波密县| 田东县| 双江| 营山县| 东平县| 沙田区| 万盛区| 巴林右旗| 安龙县| 白城市| 白玉县| 介休市| 临武县| 施甸县| 阿合奇县| 堆龙德庆县| 永丰县| 银川市|