Learn how to access your organization's Exchange Environment remotely using Microsoft PowerShell
For Exchange Online
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