Connecting to Office365 with Powershell

This article has been ported from my old TechBlog as it is still valid and useful.

To manage Office 365 you can use Powershell. Here are the steps that you need to take to get set up for doing so:

http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh124998.aspx

Then you need to connect to the service (best to have UAC disabled). Use the ‘Microsoft Online Services Module for Windows Powershell’ that you now have installed, or import the module in Powershell with:

import-module MSOnline

The credentials that you need to provide are admin credentials for your Office 365 portal – that’s how it knows which account to connect to:

$livecred = get-credential; $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection; Connect-MsolService

Now that you are connected, here are the cmdlets that you can use:

http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh125002.aspx

You may want to start with:

Get-MsolDomain