Tag: Microsoft

Connect to Office 365 with Powershell

Connect to Office 365 with Powershell

Using the Office 365 web interface to manage a tenant isn’t always the most ideal choice, based on what you’re trying to accomplish, especially if you would like to automatic or perform bulk tasks. Luckily Microsoft provides cmdlets that let you connect to Office 365 with Powershell.


Install Microsoft .NET Framework 4.5.x

Install Windows Management Framework 3.0 or 4.0

Install Microsoft Online Services Sign-In Assistant for IT Professionals RTW

Install Azure AD Module for Windows PowerShell (x86 or x64)

Launch Powershell

You will want to right click Powershell and use Run as Administrator.

Load Required Modules

Once you have Powershell launched, the first thing you will want to do is load modules that you will need to connect to Office 365 using Powershell. Issue the following command in the Powershell window to load the MsOnline module.

Import-Module MsOnline

Office 365 Credentials

Now that you have the MsOnline module loaded you’re going to need to get and store your Office 365 credential in a variable. Issue the following command in the Powershell window. Once you do, it will launch a window requesting your username and password for Office 365.

$cred = Get-Credential

Getting Office 365 Credential

Connecting to Office 365

With the credential stored you can now use it to connect to the service.

Connect-MsolService -Credential $cred

If authentication was successful you are now connected to your Office 365 organization and can manage your service from there.

Connect to Office 365 with Powershell