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.
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
https://www.powershellgallery.com/packages/Microsoft.Online.SharePoint.PowerShell/Downloadhttps://go.microsoft.com/fwlink/p/?LinkId=255251DownloadAlso 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.
7 steps
- 1
Open PowerShell as administrator
Where: Windows PC: Start > type PowerShell > right-click Windows PowerShell (or PowerShell 7) > Run as administratorStart an elevated PowerShell window. If you do not have admin rights, start it normally and use the
-Scope CurrentUsercommand in the install step.$PSVersionTable.PSVersionYou should see: The version shows 5.1 (Windows PowerShell) or 7.x (PowerShell 7). - 2
Check for an existing install
Where: The elevated PowerShell windowSee whether the module is already installed and which version.
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,VersionYou should see: Either nothing is returned (not installed) or a version number is listed. - 3
Install the module
Where: The elevated PowerShell windowInstall 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 CurrentUserYou should see: The prompt returns without errors. Running the Get-Module command again lists a version. - 4
Update an older install
Where: The elevated PowerShell windowIf 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.PowerShellYou should see: Get-Module -ListAvailable shows the newer version. - 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 -UseWindowsPowerShellYou should see: A warning that the module is loaded through Windows PowerShell compatibility may appear; the prompt then returns. - 6
Connect with multifactor authentication
Where: PowerShell on the Windows PCConnect 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.comYou should see: The prompt returns with no error. You are ready to use SharePoint Online commands. - 7
If the connection fails, use modern authentication
Where: PowerShell on the Windows PCIf 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/organizationsYou should see: A sign-in window opens and the connection completes.
Expert tips
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.
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.
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.
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.
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.
How to confirm it worked
Run
Get-SPOTenant | Select-Object SharingCapability. A value such asExternalUserAndGuestSharingorDisabledmeans you are connected to the tenant.Run
Get-SPOSite -Limit 5and check it lists sites from your tenant.Run
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Versionand compare with the latest version on the PowerShell Gallery page.
How to reverse it
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.
Errors you might see
Could not connect to SharePoint OnlineCause: 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 loadCause: 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 consoleCause: Microsoft states the module must be imported with -UseWindowsPowerShell in PowerShell 7.
Fix: Run Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell first.
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.
Official sources
Vendors change menus and requirements. Confirm on the source before you rely on a detail. Last checked 4 Nov 2026.