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.
Install Microsoft .NET Framework 4.5.x
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
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.