Connect to Exchange Online via PowerShell

Problem: How do I connect to my Office 365 Exchange environment via PowerShell?

Solution:

Run the below code in a PowerShell window to make the connection.

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

 

[amazon_link asins=’1787126935′ template=’ProductAd’ store=’dailysysadmin-21′ marketplace=’UK’ link_id=’ef569912-868d-11e7-b234-67d6afe881c4′]

 

The $UserCredential = Get-Credential line will prompt you for a username and password. Enter your administrator credentials here, standard user accounts will not have the appropriate permissions.

 

You may need to alter you execution policy if you have not yet run any unsigned PowerShell scripts on your machine.

Set-ExecutionPolicy -ExecutionPolicy unrestricted

Leave a Reply

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