Connecting to Microsoft 365 Services with Powershell

1. Microsoft Entra ID (Formerly Azure AD/MSOL)

This is the direct replacement for the MSOL and AzureAD modules.

  • Module: Microsoft.Graph
  • Connection Command:PowerShellConnect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "Directory.ReadWrite.All" Note: Unlike the old modules, Graph requires you to specify “Scopes” (permissions) for what you intend to do.

2. Exchange Online

  • Module: ExchangeOnlineManagement
  • Connection Command:PowerShellConnect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

3. SharePoint Online

  • Module: Microsoft.Online.SharePoint.PowerShell
  • Connection Command:PowerShellConnect-SPOService -Url "https://yourtenant-admin.sharepoint.com"

4. Microsoft Teams

  • Module: MicrosoftTeams
  • Connection Command:PowerShellConnect-MicrosoftTeams

5. Security & Compliance Center

This uses the same module as Exchange but a different connection string.

  • Module: ExchangeOnlineManagement
  • Connection Command:PowerShellConnect-IPPSSession -UserPrincipalName admin@yourdomain.com

One-Time Setup (Installation)

If you haven’t installed these modules yet, run these commands in an Administrative PowerShell window:

PowerShell

# Install the core modules
Install-Module -Name Microsoft.Graph -Scope CurrentUser
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
Install-Module -Name MicrosoftTeams -Scope CurrentUser
Scroll to Top