How To: Connect to Office 365 using PowerShell

When managing Office 365, you may find that some tasks are easier using PowerShell rather than the Office 365 Admin portal. This guide will show you how to install the needed tools to connect to an Office 365 tenant.

Prerequisites

  • x64 version of Windows 10, Windows 8.1, Windows 8 or Windows 7 Service Pack 1
  • Windows Server 2016, Windows Server 2012 R2, Windows Server 2012 or Windows Server 2008 R2 Service Pack 1
  • Office 365 Global Administrator Credentials

Download and Install Necessary Software Packages

  1. Download and install the 64 Bit version of the Microsoft Online Services Sign-In Assistant from https://www.microsoft.com/en-us/download/details.aspx?id=41950
  2. Download and install the 64 Bit version of the Microsoft Windows Azure Active Directory Module for Powershell from http://go.microsoft.com/fwlink/p/?linkid=236297

Connecting to Office 365 from Powershell

  1. Click Start and in the start search, type Azure. Locate and open Windows Azure Active Directory Module for Windows PowerShell
    %ef%bb%bfwindows-azure-active-directory-module-for-windows-powershell

  2. Enter the command $UserCredential = Get-Credential and press the Enter key.
  3. In the Windows PowerShell Credential Request window, enter the address of your Office 365 Global administrator account and the password, then click OK.

    windows-powershell-credential-request

  4. Finally, enter the command Connect-MsolService -Credential $UserCredential
    and press the Enter key.

    azure-office-365-powershell-window

 

You can now use the PowerShell commands to administer Office 365. For more information, visit: https://technet.microsoft.com/en-us/library/dn975125.aspx