Connect To All Office 365 Services With PowerShell

Since I had to accumulate the following through trial and error of outdated links and outdated technet articles, I have created the up to date defacto version of how to connect to all Office 365 sessions through PowerShell. I divided each service up into its own section along with a combined function to connect to all services.

Prerequisites: Download and install the following:
1) Microsoft .NET Framework 4.5.2
2) Windows Management Framework 4.0
3) Microsoft Online Services Sign-in Assistant for IT Professionals RTW (64-bit version)
4) Windows Azure Active Directory Module for Windows PowerShell (64-bit version)
5) Skype for Business Online Windows PowerShell Module
6) SharePoint Online Management Shell
7) Execution policy of PowerShell needs to be at least RemoteSigned.

Step #1: The first step is to enter your office 365 credentials. This would be your Office 365 sign in information that has the required privileges.

Step #2: Office 365 tenant – The next step is to connect to the online tenant.

Step #3: SharePoint Online – In no particular order we can next connect to SharePoint Online. *Replace yourtenantnamehere with your tenant name.

Step #4: Skype For Business Online – Next up on our list is Skype For Business Online. If you have Lync / Skype For Business on premise you will need to utilize the -OverrideAdminDomain parameter. *Replace yourtenantnamehere with your tenant name.

Step #5: Exchange Online – The following command will connect to Exchange Online.

Step #6: Office 365 Compliance – The final service is Office 365 Compliance.

Step #7: We can now combine all of our service connections into one function called Connect-Office365.

Step #8: As with any remote PowerShell session, you will want to clean up your sessions when you disconnect. Here is a function for that very purpose.

Feel free to leave comments, suggestions, or requests in the comments.

Print Friendly, PDF & Email


  1. ajhstn

    You can also encrypt your credential with Export-Clixml -Path, then just import and decrypt it at connect time to automate.

    Also with the newest Azure AD cmdlets we don’t need the signin assistant anymore.

  2. Rob de Jong

    Hi Steve,

    I noticed you are using the older MSOnline PowerShell module in your examples. It may be useful to start using the newer Azure Active Directory PowerShell V2 module instead, as we will begin deprecating the MSOnline module when we have migrated the functionality of the MSOnline module to the newer module – currently planned for the Spring of 2017.


    Rob de Jong

Leave a Reply

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