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
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.
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
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.