Connect to Exchange Online PowerShell

If you’re new to Office 365, you’ll almost certainly need to connect to the Exchange Online PowerShell at some point. It’s effectively the same as the Exchange Management Shell for on-premise Exchange servers only you’re connecting to your Office 365 tentant.

Before you start, you’ll need to install the following:

Once installed, you’ll need to set the PowerShell execution policy otherwise certain scripts won’t run:

Set-ExecutionPolicy RemoteSigned

You only need to set the execution policy once per machine you use to connect and you’ll need to run PowerShell as admin.

Next, run the following and enter your Office 365 admin credentials:

$UserCredential = Get-Credential

Then run each command one after the other:

Connect-MsolService -Credential $UserCredential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection

Import-PSSession $Session

You should then be connected and can do whatever you need to do.

Leave a Reply

Your email address will not be published. Required fields are marked *