Connect to Azure AD/Office 365 via PowerShell
The Problem
The majority of tasks to do with Office 365 can be accomplished via the GUI, however there are often situations where you need to connect via PowerShell to toggle certain features. Connect to Azure AD/Office 365 via PowerShell.
The Fix
To connect to Office 365 via PowerShell, you will need:
Once installed, run the Azure AD PowerShell app and run the following:
- $UserCredential = Get-Credential
- Type the admin credentials for Office 365
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Import-PSSession $Session
You are now connected to Office 365 via PowerShell! Go and run your commands!