Connecting to Office 365 “Everything” via PowerShell

Microsoft is continually evolving their cloud hosted offerings, whether it’s called “Microsoft Online”, “Office 365”, “SharePoint Online”, “Exchange Online”, etc…

All of it is coming together, but there are a lot of services and different ways to connect to each one of them. The Office 365 umbrella can be simple though, once you reign in all the parts. I just came across this very useful post that shows you step by step how to connect to all the various services, so I wanted to go through it and document the steps for my own reference.

This can useful if you want to make your own reusable “connect me to everything” script used before performing any admin tasks on your hosted tenant environment in Office 365.

The article I am referring to is this one:
Connect to all Office 365 services in a single Windows PowerShell window


My preparation (one-time steps) for my Windows 10 test machine were:

First, ensure the Microsoft Online Services Sign-in Assistant for IT Professionals RTW is installed.


Next, ensure the Windows Azure Active Directory Module for Windows PowerShell is installed.


Next, ensure the SharePoint Online Management Shell is installed.


Finally, ensure the Skype for Business Online PowerShell Module is installed.

* There are other requirements, such as .NET and WMF components, but I didn’t need to install them on my Windows 10 machine, so you may or may not have to depending on your system.


My connection process for each time I want to connect is:

$credential = Get-Credential


You’ll be prompted to enter your Office 365 sign-in details.


Import-Module MsOnline
Connect-MsolService -Credential $credential


$spUrl = " "
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url $spUrl -credential $credential


Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession


$connectionUri = " "
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $connectionUri -Credential $credential -Authentication “Basic” -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking


$connectionUri = " "
$ccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $connectionUri -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $ccSession -Prefix cc


Once you’re connected, you can now start doing things! Just a basic example, running Get-MsolSubscription to pull current license details.


When I want to close out all the connections:

Remove-PSSession $sfboSession ; Remove-PSSession $exchangeSession ; Remove-PSSession $ccSession ; Disconnect-SPOService


One thought on “Connecting to Office 365 “Everything” via PowerShell

  1. Pingback: Connect to all PowerShell Modules in O365 with one script – IT Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s