Connect to Exchange Online with Powershell

In my previous post I talked about using Powershell to connect to Office 365 to manage the service. Using that method you will be able to manage user accounts and other settings that only apply to the Office 365 service itself. If you would like to connect to Exchange Online with Powershell to manage users’ mailboxes then Microsoft also provides cmdlets that allow you to perform these tasks.

Prerequisites

Install Microsoft .NET Framework 4.5.x

Install Windows Management Framework 3.0 or 4.0

Launch Powershell

You will want to right click Powershell and use Run as Administrator.

Office 365 Credentials

Now that you have the Powershell window ready to go, issue the following command in the Powershell window. Once you do, it will launch a window requesting your username and password for Office 365.

$cred = Get-Credential

Getting Office 365 Credential

Connecting to Exchange Online

With the credential stored you can now use it to connect to the Exchange Online service.

$exchSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://outlook.office365.com/powershell-liveid/” -Credential $credential -Authentication “Basic” -AllowRedirection

If authentication was successful, you are now connected to your Exchange Online organization and can manage your service from there.

Disconnecting from Exchange Online

Once you’ve finished the Exchange Online management tasks in Powershell you will then need to free up your session by removing it.

Remove-PSSession $exchSession

Connecting to Exchange Online with Powershell

Leave a Reply

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