03 February 2015

Connect to Exchange Powershell website remotely (Office 365) and Exchange Server 2010, 2013

Start Powershell as a administrator

Run Windows PowerShell and check your Execution policy settings:
Get-ExecutionPolicy
If the execution policy is set to Restricted please change it to RemoteSigned or Unrestricted:
Set-ExecutionPolicy RemoteSigned
Provide the target server administrator credentials:
$LiveCred = Get-Credential
Configure the connection:
In the case of connecting to Exchange Server 2010, 2013:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://<target-server-address>/powershell/ -Credential $LiveCred
In the case of connecting to Exchange Online (Office 365):
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Start the connection:
Import-PSSession $Session
To disconnect type in:
Remove-PSSession $Session