How to Connect to Office 365 via Powershell

This is a quick and dirty guide on how to connect to the office365 platform via powershell.

To connect to The Microsoft Office 365 Platform via Powershell you will first need to install a few prerequisites.

First start with the Microsoft Online Services Sign-In Assistant for IT Professionals RTW

Next you’ll need to install the Azure Active Directory Module for Windows PowerShell (64-bit version)

Then open Powershell as an administrator and run:
Set-ExecutionPolicy RemoteSigned

Now set your Office365 admin credentials
$credential = Get-Credential

Then Import the MSOnline Module
Import-Module MsOnline

Make the connection to Office 365 with
Connect-MsolService -Credential $credential

And link to exchange online with
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “” -Credential $credential -Authentication “Basic” -AllowRedirection
Import-PSSession $exchangeSession

If you have sharepoint connect with
Import-Module Microsoft.Online.SharePoint.PowerShell
Connect-SPOService -Url https://[YOURCOMPANYDOMAINHOST] -credential $credential

You can also connect to lync online with
Import-Module LyncOnlineConnector
$lyncSession = New-CsOnlineSession -Credential $credential
Import-PSSession $lyncSession