Managing Office365 with PowerShell

by Dec 18, 2013

Did you know that you can manage your Office365 accounts with PowerShell, too? Provided you have an Office365 account, try this:

$OfficeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential (Get-Credential) -Authentication Basic -AllowRedirection

$import = Import-PSSession $OfficeSession -Prefix Off365

Get-Command -Noun Off365* 

This will connect to Office 365 with your credentials, and then import the PowerShell cmdlets you can use to manage it. You'll get roughly 400 new cmdlets. If you get an "Access Denied" instead, then your account may not have sufficient privileges, or you mistyped your password.

Note that all imported cmdlets are prefixed with "Off365", so to view all mailboxes, try this:


You can choose the prefix yourself (see code above) which enables you to connect to multiple Office365 accounts at the same time and using different prefixes. You can omit the prefix, too, when you run Import-PSSession.

To view the new commands that were exported by Office365, use this:


Twitter This Tip! ReTweet this Tip!