Connecting to Exchange Online with PowerShell

Really quick one for y’all today. Working with Intune, I’ve found myself becoming a bit of an Exchange SME. Blocking email, authentication types, EAS vs EWS, the list goes on.

Anyway, I find myself having to query Exchange Online configuration all the time.

Here’s a three line PowerShell script that will connect you to your Exchange Online tenant and allow you to use any of the Exchange Cmdlets

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

Run this and you can then start working with Exchange Online from the console!

image

Matt Shadbolt
Senior Program Manager
Enterprise Client and Mobility – Intune