How do I connect to Exchange using Remote PowerShell?

For Exchange Online (Office 365), execute the following commands in PowerShell:

$Credentials = Get-Credential
Import-Module MSOnline
Connect-MsolService -Credential $Credentials
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Authentication Basic -Credential $Credentials -AllowRedirection
Set-ExecutionPolicy RemoteSigned
Import-PSSession $Session

You will be asked to supply valid Office 365 credentials.

For Exchange 2013, execute the following commands in PowerShell, where CAS FQDN is the fully qualified domain name of an Exchange 2013 Client Access Server:

$Credentials = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://<CAS FQDN>/PowerShell/" -Authentication Kerberos -Credential $Credentials
Set-ExecutionPolicy RemoteSigned
Import-PSSession $Session

You will be asked to supply valid Exchange credentials.

No matter if you are using Exchange Online or Exchange 2013, you should disconnect the remote PowerShell session when you are finished by executing the following command:

Remove-PSSession $Session
Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.