PowerShell Connect to Exchange Online

In our previous article, PowerShell connect to AzureAD,  we’ve shown how to install and connect to AzureAD inorder to manage Microsoft 365 user and settings . However these does not have access to other settings hosted with Microsoft 365 like Exchange.  So, follow these steps to connect to Exchange Online.

Connect to Exchange Online using PowerShell without multifactor authentication enabled

PS C:\WINDOWS\system32> Import-Module MSOnline

For admin accounts without multifactor authentication, use the Get-Credential method.

###create credential object

PS C:\WINDOWS\system32> $Credential = Get-Credential

###build session

PS C:\WINDOWS\system32> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic –AllowRedirection

###import into PowerShell session

PS C:\WINDOWS\system32> Import-PSSession $Session