Connect-SPOService: Connect to SharePoint Online in PowerShell

3 min read James Futhey Updated November 13, 2026
Microsoft Learn documentation for the Connect-SPOService cmdlet showing its PowerShell syntax

Quick answer: Install the SharePoint Online Management Shell module, then run Connect-SPOService -Url https://contoso-admin.sharepoint.com. Leave out -Credential and you get a sign-in prompt, which is the method that works with MFA. Connect-SPOService must run before any other SharePoint Online (SPO) cmdlet.

What does Connect-SPOService do?

Connect-SPOService connects a SharePoint Administrator (or SharePoint Embedded Administrator) to the SharePoint Online admin center. Every other SPO cmdlet, such as Get-SPOSite or Set-SPOTenant, needs this connection first.

You get one connection per PowerShell session and per geo location. Running Connect-SPOService again replaces the existing connection.

How do I install the SharePoint Online PowerShell module?

Task Command
Check if it's installed Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
Install (as administrator) Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Install (no admin rights) Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
Update Update-Module -Name Microsoft.Online.SharePoint.PowerShell

Using PowerShell 7

In PowerShell 7, import the module through Windows PowerShell compatibility before connecting:

Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell

How do I connect to SharePoint Online?

Use your tenant's admin URL, which follows the format https://<tenant>-admin.sharepoint.com.

Connect-SPOService -Url https://contoso-admin.sharepoint.com

This opens a sign-in prompt. Microsoft requires this prompt method for accounts with multi-factor authentication (MFA).

Which sign-in method should I use?

Method Example When to use it
Interactive prompt Connect-SPOService -Url https://contoso-admin.sharepoint.com Accounts with MFA; most admins
Credential object Connect-SPOService -Url https://contoso-admin.sharepoint.com -Credential admin@contoso.com Accounts without MFA
Modern authentication Connect-SPOService -Credential $creds -Url https://contoso-admin.sharepoint.com -ModernAuth $true -AuthenticationUrl https://login.microsoftonline.com/organizations Fixing "Could not connect to SharePoint Online"
System browser Connect-SPOService -Url https://contoso-admin.sharepoint.com -UseSystemBrowser $true Sign-in through your default browser (MSAL)
Certificate Connect-SPOService -Url https://contoso-admin.sharepoint.com -ClientId <app-id> -TenantId <tenant-id> -CertificateThumbprint "<thumbprint>" Unattended scripts with an app registration
Managed identity Connect-SPOService -Url https://contoso-admin.sharepoint.com -ManagedIdentity Scripts running in Azure

Notes:

  • -ModernAuth needs -AuthenticationUrl as well.
  • To use the system browser by default, set the UseSystemBrowser DWORD value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SPO\CMDLETS\ instead of passing the switch.
  • To store credentials in a variable for -Credential, see Get-Credential in PowerShell.

What does the -Region parameter do?

Most tenants never need it. Set it only when your tenant lives in a special cloud.

Region Use for
Default Most tenants (the default)
ITAR GCC High and DoD tenants only
Delos German sovereign cloud tenants only

The other valid values are France, Germany and China.

How do I check the connection and disconnect?

List sites to confirm you're connected:

Get-SPOSite

End the session when you're done:

Disconnect-SPOService

Troubleshooting

Symptom Cause Fix
Connect-SPOService is not recognized Module not installed, or not imported in PowerShell 7 Install the module; in PowerShell 7 use Import-Module ... -UseWindowsPowerShell
"Could not connect to SharePoint Online" Legacy sign-in blocked Use the modern authentication example above
Module fails to load SharePoint Client Components SDK also installed Uninstall the SDK, then reopen PowerShell
Sign-in fails with MFA -Credential used on an MFA account Drop -Credential and sign in at the prompt
Wrong or missing sites Connected to a different geo or tenant Run Connect-SPOService again with the right admin URL

Summary

  • Install Microsoft.Online.SharePoint.PowerShell, then connect to https://<tenant>-admin.sharepoint.com.
  • Skip -Credential for MFA accounts and sign in at the prompt.
  • Use certificates or managed identity for unattended scripts.
  • Set -Region only for GCC High, DoD or other special clouds.
  • Run Disconnect-SPOService when finished.

Related: Connect-PnPOnline, Connect-MgGraph, Connect-MicrosoftTeams, Enable-PSRemoting.

Meeting Room 365 turns any iPad or Android tablet into a room display for Exchange and Microsoft 365 calendars. See the features or pricing: $9 a display a month.

Add a display to your office

Every room, on the door.

Live availability on every meeting room. Works with Microsoft 365, Exchange and Google Workspace.