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:
- Microsoft Online Services Sign-In Assistant for IT Professionals RTW
- Windows Azure Active Directory Module for Windows PowerShell
Once installed, you’ll need to set the PowerShell execution policy otherwise certain scripts won’t run:
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
You should then be connected and can do whatever you need to do.