How-to · SharePoint and OneDrive

Install SharePoint Online Management Shell and connect

At the end you will have the Microsoft.Online.SharePoint.PowerShell module installed on a Windows PC and an authenticated Connect-SPOService session to your SharePoint admin URL, ready to run SPO cmdlets.

Updated 7 steps2 official sources
Before you start

What you need before step 1

Applies to: SharePoint Online Management Shell (Microsoft.Online.SharePoint.PowerShell) for SharePoint in Microsoft 365, in Windows PowerShell 5.1 or PowerShell 7 on Windows (as documented).

Admin roles you need

  • SharePoint Administrator in Microsoft 365 (Global Administrator also works, but Microsoft recommends least privilege)

Licences

None needed.

Download

Microsoft.Online.SharePoint.PowerShell (PowerShell Gallery)Install with Install-Module. Published by MicrosoftSharePoint.https://www.powershellgallery.com/packages/Microsoft.Online.SharePoint.PowerShell/Download
SharePoint Online Management Shell installerThe standalone installer Microsoft Learn links to, if you cannot use the PowerShell Gallery.https://go.microsoft.com/fwlink/p/?LinkId=255251Download

Also have ready

  • A Windows PC. Microsoft documents only Windows install routes, and the PowerShell 7 route uses Windows PowerShell compatibility, so there is no documented macOS route.
  • Your tenant name, which forms the admin URL. If your SharePoint site is https://contoso.sharepoint.com, the admin URL is https://contoso-admin.sharepoint.com.
  • Local administrator rights for an all-users install, or use -Scope CurrentUser without them.
  • If the SharePoint Client Components SDK is installed, plan to remove it: Microsoft lists a known issue where the module fails to load when both are installed.
Step by step

7 steps

  1. 1

    Open PowerShell as administrator

    Where: Windows PC: Start > type PowerShell > right-click Windows PowerShell (or PowerShell 7) > Run as administrator

    Start an elevated PowerShell window. If you do not have admin rights, start it normally and use the -Scope CurrentUser command in the install step.

    $PSVersionTable.PSVersion
    You should see: The version shows 5.1 (Windows PowerShell) or 7.x (PowerShell 7).
  2. 2

    Check for an existing install

    Where: The elevated PowerShell window

    See whether the module is already installed and which version.

    Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
    You should see: Either nothing is returned (not installed) or a version number is listed.
  3. 3

    Install the module

    Where: The elevated PowerShell window

    Install from the PowerShell Gallery. Answer Y if asked to trust the PSGallery repository or install the NuGet provider. Without admin rights, use the second command.

    Install-Module -Name Microsoft.Online.SharePoint.PowerShell
    Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
    You should see: The prompt returns without errors. Running the Get-Module command again lists a version.
  4. 4

    Update an older install

    Where: The elevated PowerShell window

    If you already had the module, update it so you have all current cmdlets. Microsoft notes older versions may lack later features, for example TLS 1.2 negotiation.

    Update-Module -Name Microsoft.Online.SharePoint.PowerShell
    You should see: Get-Module -ListAvailable shows the newer version.
  5. 5

    Load the module in PowerShell 7

    Where: PowerShell 7 on the Windows PC (skip this step in Windows PowerShell 5.1)

    Microsoft states that to run SharePoint Online commands in a PowerShell 7 console you must import the module with -UseWindowsPowerShell.

    Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell
    You should see: A warning that the module is loaded through Windows PowerShell compatibility may appear; the prompt then returns.
  6. 6

    Connect with multifactor authentication

    Where: PowerShell on the Windows PC

    Connect to the admin URL (with -admin), not your normal site URL. In the Microsoft SharePoint Online Management Shell dialog, enter your SharePoint administrator account and password, select Sign in, then complete the verification prompt.

    Connect-SPOService -Url https://contoso-admin.sharepoint.com
    You should see: The prompt returns with no error. You are ready to use SharePoint Online commands.
  7. 7

    If the connection fails, use modern authentication

    Where: PowerShell on the Windows PC

    If you get Could not connect to SharePoint Online, Microsoft suggests connecting with modern authentication explicitly.

    Connect-SPOService -Url https://contoso-admin.sharepoint.com -ModernAuth $true -AuthenticationUrl https://login.microsoftonline.com/organizations
    You should see: A sign-in window opens and the connection completes.
From experience

Expert tips

In PowerShell 7, import with -UseWindowsPowerShell

Microsoft states SPO cmdlets need Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell in a PowerShell 7 console. Put that line at the top of migration scripts so they work on any admin PC, or simply run them in Windows PowerShell 5.1.

Pick one install method

The PowerShell Gallery module and the standalone installer can both end up on the same PC, and PowerShell may load the older copy. If Get-Module -ListAvailable lists two versions, remove the standalone one from Installed apps and keep the Gallery module, which you update with Update-Module.

Connect to the -admin URL

Always connect to https://contoso-admin.sharepoint.com, built from your tenant name rather than any custom domain. Connecting to the normal site URL is the most common reason Connect-SPOService fails. If it still fails, add -ModernAuth $true -AuthenticationUrl https://login.microsoftonline.com/organizations.

Remove the Client Components SDK if the module will not load

Microsoft lists a known conflict when the SharePoint Client Components SDK is installed on the same computer. Older migration and reporting tools often install it, so check Installed apps first if the import fails with no obvious reason.

Use it for a quick site inventory before migrating

Once connected, Get-SPOSite -Limit All lists every site collection, which is a fast way to build the source or target inventory for a SharePoint or OneDrive migration. Keep the module updated, as Microsoft notes older versions lack later features such as TLS 1.2 negotiation.

Check it worked

How to confirm it worked

  • Run Get-SPOTenant | Select-Object SharingCapability. A value such as ExternalUserAndGuestSharing or Disabled means you are connected to the tenant.

  • Run Get-SPOSite -Limit 5 and check it lists sites from your tenant.

  • Run Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version and compare with the latest version on the PowerShell Gallery page.

Undo

How to reverse it

Rollback:

End the session with Disconnect-SPOService. To remove the module installed from the PowerShell Gallery, run Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell in an elevated window. If you used the standalone installer, remove SharePoint Online Management Shell from Settings > Apps > Installed apps. Nothing in the tenant changes.

Troubleshooting

Errors you might see

Could not connect to SharePoint Online

Cause: Microsoft does not state a single cause; it advises that you may need modern authentication.

Fix: Connect with -ModernAuth $true -AuthenticationUrl https://login.microsoftonline.com/organizations, or use the MFA sign-in without -Credential.

The module fails to load

Cause: Microsoft lists a known conflict when the SharePoint Client Components SDK is installed on the same computer.

Fix: Uninstall the SharePoint Client Components SDK, then import the module again.

SPO cmdlets do not run in a PowerShell 7 console

Cause: Microsoft states the module must be imported with -UseWindowsPowerShell in PowerShell 7.

Fix: Run Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell first.

FAQ

Questions

Which URL do I connect to?

The SharePoint admin URL, which adds -admin to your tenant name: https://contoso-admin.sharepoint.com.

Does it work in PowerShell 7?

Yes, on Windows, if you import it with -UseWindowsPowerShell as Microsoft documents.

Can I install it on a Mac?

Microsoft documents only Windows routes for this module.

Do I need to reinstall it often?

No. Install once, then run Update-Module when you need newer cmdlets.

Sources

Official sources

Vendors change menus and requirements. Confirm on the source before you rely on a detail. Last checked 4 Nov 2026.