How can you connect to an Office 365 tenant and run O365 specific cmdlets from your workstation?
This is a question that often gets asked in forums. Let’s assume that you have a tenant in Office 365 and you would like to manage it fully using PowerShell. The O365 GUI (portal) doesn’t give you all the options anyway.
Following are the steps to get connected.
1. You need Windows 7 SP1+ or Windows 2008 R2 SP1+ server as the base operating system.
2. Install Microsoft Online Services Sign-In Assistant for IT Professionals RTW on your machine.
3. Install Windows Azure Active Directory Module for Windows PowerShell (32-bit version) or Windows Azure Active Directory Module for Windows PowerShell (64-bit version) depending upon the operating system version.
4. Once the installation of the Azure module is complete, there will be a PowerShell shortcut on the desktop for the same.
5. Right click and select “Run as administrator”. An elevated PowerShell window will open up.
6. Change the PowerShell execution policy to RemoteSigned.
7. Connect to Office 365 by typing in Connect-MsolService. A new window will popup, enter the username and password for the global administrator account for your tenant.
8. You will be returned back to your prompt in the next line and you are now connected to Office 365. No message will be displayed to that effect. Run Office 365 cmdlets to verify that the connection does work.
If you don’t want to use the Windows Azure AD Module for PowerShell icon on your desktop, you can connect using a regular powershell window.
1. After installing the sign in assistant and the Azure module for powershell (step 4 above), open a regular powershell window (run as administrator).
2. Import the Azure module by running Import-Module MSOnline
3. Connect to Office 365 by running Connect-MsolService
4. Enter the username and password for the global administrator.
5. Verify connection by running an O365 cmdlet.
Now you can manage your O365 tenant fully using PowerShell ;)
Cloud Architect & Blogger with interests in Office 365, Enterprise Mobility & Security and Azure. I am active on Experts Exchange & TechNet forums and I am a technical author for SearchExchange. Follow me on Twitter, LinkedIn, Facebook or Google+ for the latest updates. For consultancy opportunities, drop me a line.