Connect to Office 365 via Powershell


Most administration of Office 365 is done using the Office 365 Admin Center ( eg license assignment, domain management, email maintenance (via Exchange Admin Center link) etc.

Administering Exchange via Powershell is still possible however there are extra steps involved due to increased security required in accessing cloud resources.

Below are the prerequisites and steps to connect to Office 365 via Powershell


  • Windows 8, 10 or 2012/R2
  • Microsoft.NET Framework 4.5 or later


1. On your local computer, open Windows Powershell (as local administrator) and run the following command.

$UserCredential = Get-Credential

In the Windows PowerShell Credential Request dialog box, type your Office 365 user name (eg admin@<tenant name> and password and then click OK.

2. Run the following command.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

3. Run the following command.

Import-PSSession $Session

4. You are now ready to enter your Powershell cmdlets,

Get-MailboxStatistics joe.bloggs | ft DisplayName, TotalItemSize, ItemCount

5. (Important) When finished do not just click the top right X. Instead disconnect the remote Powershell session properly by running the command below.

Remove-PSSession $Session

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s