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
https://technet.microsoft.com/en-us/library/dn568015.aspx
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.
http://go.microsoft.com/fwlink/p/?LinkId=286152
Next, ensure the Windows Azure Active Directory Module for Windows PowerShell is installed.
http://go.microsoft.com/fwlink/p/?linkid=236297
Next, ensure the SharePoint Online Management Shell is installed.
http://go.microsoft.com/fwlink/p/?LinkId=255251
Finally, ensure the Skype for Business Online PowerShell Module is installed.
http://go.microsoft.com/fwlink/p/?LinkId=532439
* 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 = "https://myOfficeSubscriptionName-admin.sharepoint.com "
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 = "https://outlook.office365.com/powershell-liveid/ "
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $connectionUri -Credential $credential -Authentication “Basic” -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking
$connectionUri = "https://ps.compliance.protection.outlook.com/powershell-liveid/ "
$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
Pingback: Connect to all PowerShell Modules in O365 with one script – IT Blog