How to Install the SharePoint Online PowerShell Module?

Requirement: Install SharePoint Online PowerShell module.

The SharePoint Online PowerShell Module enables administrators to manage their SharePoint Online environments using PowerShell cmdlets. This module is a great way to manage and automate your SharePoint environment. You can use it to perform a wide range of tasks you typically do in the SharePoint Admin center, including creating and managing sites, lists and libraries, users and groups, fields, content, and more. This article will show you how to install the SharePoint Online PowerShell module.

SharePoint Online Management Shell is available as a module in the PowerShell Gallery now! So, you can install it as a module directly from PowerShell instead of downloading and installing the SharePoint Online Management Shell MSI file! This makes it easier to update. Here is how to install the SharePoint Online PowerShell module:

Prerequisites: The Install-module cmdlet comes with the “PowerShellGet” module, which comes with Windows 10, Windows 2016, or later. In older operating systems, You can get it through Windows Management Framework (WMF) 5.1 or later.

How to find your SharePoint Online PowerShell version?

To get started, check if you have already installed the SharePoint Online Management Shell module in your system by running the following command in the administrative mode in PowerShell:

Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select-Object Name,Version

This finds your version of the SharePoint Online PowerShell module installed.

How to Install SharePoint Online PowerShell Module?

How do I install SharePoint Online Management Shell from PowerShell? The SharePoint Online Management Shell is a Windows PowerShell module installed in your Windows client machine or Server (Unlike the SharePoint Server PowerShell that can be accessed only from any of the Server of the Server Farm). To install the PowerShell Module for SharePoint Online, Open PowerShell as Administrator and enter:

Install-Module Microsoft.Online.SharePoint.PowerShell

install sharepoint online powershell module
Confirm the prompt, and you’ll see the PowerShell module for SharePoint Online starts downloading and installing:

sharepoint online powershell module install

This installs the latest SharePoint Online PowerShell module from PowerShell Gallery and allows administrators to manage the SharePoint Online environment, including OneDrive, using PowerShell cmdlets.

Re-install the SharePoint Online PowerShell module

To re-install the SharePoint Online PowerShell module, use: -Force switch:

Install-Module Microsoft.Online.SharePoint.PowerShell -force

Please note, installing the PowerShell module for SharePoint Online doesn’t install “SharePoint Online Management Shell” on your PC. Still, you can run any SharePoint Online cmdlets directly in Windows PowerShell itself!

Let’s check If the SharePoint Online PowerShell Module is installed. If not, install it.

#Check if SharePoint Online PowerShell module has been installed
Try {
    Write-host "Checking if SharePoint Online PowerShell Module is Installed..." -f Yellow -NoNewline
    $SharePointOnlineModule = Get-Module -ListAvailable "Microsoft.Online.SharePoint.PowerShell"

    #Check if SharePoint Online Module is installed
    If(!$SharePointOnlineModule)
    {
        Write-host "No!" -f Green

        #Check if script is executed under elevated user permissions - Run as Administrator
        If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
        {   
            Write-Host "Please Run this script in elevated mode (Run as Administrator)! " -NoNewline
            Read-Host "Press any key to continue"
            Exit
        }

        Write-host "Installing SharePoint Online PowerShell Module..." -f Yellow -NoNewline
        Install-Module "Microsoft.Online.SharePoint.PowerShell" -Force -Confirm:$False
        Write-host "Done!" -f Green
    }
    Else
    {
        Write-host "Yes!" -f Green
        #sharepoint online powershell module import
        Write-host "Importing SharePoint Online PowerShell Module..." -f Yellow  -NoNewline
        Import-Module "Microsoft.Online.SharePoint.PowerShell" -DisableNameChecking
        Write-host "Done!" -f Green
    }
}
Catch{
    write-host "Error: $($_.Exception.Message)" -foregroundcolor red
}

How do I connect SharePoint Online to PowerShell?

Once installed, You can connect to the SharePoint Online tenant from PowerShell and start using SharePoint Online PowerShell cmdlets. Ensure you are in the SharePoint Administrator or Global Administrator role to connect to SharePoint Online.

  • Step 1: Import SharePoint Online PowerShell module
  • Step 2: Connect to SharePoint Online from PowerShell using the Connect-SPOService cmdlet
  • Step 3: Run PowerShell cmdlets for SharePoint Online, E.g., Get all site collections
#Import PowerShell module for SharePoint Online 
Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking

#Connect to SharePoint Online Service and create a PowerShell session
Connect-SPOService -url "https://crescent-admin.sharepoint.com" -Credential (Get-Credential)

#Get All SharePoint Sites
Get-SPOSite

This PowerShell script prompts for username and password (You can leave the credential parameter to connect from Multifactor authentication – MFA enabled account), Connects to SharePoint Online, and gets all SharePoint Online sites using Get-SPOSite cmdlet. Make sure you change the site URL according to your environment. More on connecting to SharePoint Online from PowerShell: How to Connect to SharePoint Online from PowerShell?

Update SharePoint Online PowerShell module

How to update the SharePoint Online management shell? To update the SharePoint Online PowerShell Module, use the below command:

Update-module microsoft.online.sharepoint.powershell

Type “A” to confirm Yes to All, and hit enter to update the PowerShell module for SharePoint Online.

Update microsoft.online.sharepoint.powershell module

Uninstall SharePoint Online PowerShell Module

To remove the SharePoint Online PowerShell module, use the below cmdlets:

Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell

Use the “-AllVersions” switch if you have more than one version installed. Make sure you run these cmdlets as Administrator in the PowerShell console.

SharePoint Online PowerShell commands

Once you have the SharePoint Online PowerShell module installed, You can get a list of cmdlets from the module using:

Get-command -Module Microsoft.Online.SharePoint.PowerShell
Get-command -Module Microsoft.Online.SharePoint.PowerShell
Cmdlet Name
Add-SPOGeoAdministrator
Add-SPOHubSiteAssociation
Add-SPOHubToHubAssociation
Add-SPOOrgAssetsLibrary
Add-SPOSiteCollectionAppCatalog
Add-SPOSiteDesign
Add-SPOSiteDesignTask
Add-SPOSiteScript
Add-SPOSiteScriptPackage
Add-SPOTenantCdnOrigin
Add-SPOTheme
Add-SPOUser
Approve-SPOTenantServicePrincipalPermissionGrant
Approve-SPOTenantServicePrincipalPermissionRequest
Connect-SPOService
ConvertTo-SPOMigrationEncryptedPackage
ConvertTo-SPOMigrationTargetedPackage
Deny-SPOTenantServicePrincipalPermissionRequest
Disable-SPOTenantServicePrincipal
Disconnect-SPOService
Enable-SPOCommSite
Enable-SPOTenantServicePrincipal
Export-SPOQueryLogs
Export-SPOUserInfo
Export-SPOUserProfile
Get-IsCommSite
Get-SPOAppErrors
Get-SPOAppInfo
Get-SPOBrowserIdleSignOut
Get-SPOBuiltInDesignPackageVisibility
Get-SPOCrossGeoMovedUsers
Get-SPOCrossGeoMoveReport
Get-SPOCrossGeoUsers
Get-SPODataEncryptionPolicy
Get-SPODeletedSite
Get-SPOExternalUser
Get-SPOGeoAdministrator
Get-SPOGeoMoveCrossCompatibilityStatus
Get-SPOGeoStorageQuota
Get-SPOHideDefaultThemes
Get-SPOHomeSite
Get-SPOHubSite
Get-SPOKnowledgeHubSite
Get-SPOMigrationJobProgress
Get-SPOMigrationJobStatus
Get-SPOMultiGeoCompanyAllowedDataLocation
Get-SPOMultiGeoExperience
Get-SPOOrgAssetsLibrary
Get-SPOOrgNewsSite
Get-SPOPublicCdnOrigins
Get-SPOSite
Get-SPOSiteCollectionAppCatalogs
Get-SPOSiteContentMoveState
Get-SPOSiteDataEncryptionPolicy
Get-SPOSiteDesign
Get-SPOSiteDesignRights
Get-SPOSiteDesignRun
Get-SPOSiteDesignRunStatus
Get-SPOSiteDesignTask
Get-SPOSiteGroup
Get-SPOSiteRenameState
Get-SPOSiteScript
Get-SPOSiteScriptFromList
Get-SPOSiteScriptFromWeb
Get-SPOSiteUserInvitations
Get-SPOStorageEntity
Get-SPOStructuralNavigationCacheSiteState
Get-SPOStructuralNavigationCacheWebState
Get-SPOTenant
Get-SPOTenantCdnEnabled
Get-SPOTenantCdnOrigins
Get-SPOTenantCdnPolicies
Get-SPOTenantContentTypeReplicationParameters
Get-SPOTenantLogEntry
Get-SPOTenantLogLastAvailableTimeInUtc
Get-SPOTenantOrgRelation
Get-SPOTenantOrgRelationByPartner
Get-SPOTenantOrgRelationByScenario
Get-SPOTenantServicePrincipalPermissionGrants
Get-SPOTenantServicePrincipalPermissionRequests
Get-SPOTenantSyncClientRestriction
Get-SPOTenantTaxonomyReplicationParameters
Get-SPOTheme
Get-SPOUnifiedGroup
Get-SPOUnifiedGroupMoveState
Get-SPOUser
Get-SPOUserAndContentMoveState
Get-SPOUserOneDriveLocation
Get-SPOWebTemplate
Grant-SPOHubSiteRights
Grant-SPOSiteDesignRights
Invoke-SPOMigrationEncryptUploadSubmit
Invoke-SPOSiteDesign
Invoke-SPOSiteSwap
New-SPOMigrationEncryptionParameters
New-SPOMigrationPackage
New-SPOPublicCdnOrigin
New-SPOSdnProvider
New-SPOSite
New-SPOSiteGroup
New-SPOSiteSharingReportJob
New-SPOTenantOrgRelation
Register-SPODataEncryptionPolicy
Register-SPOHubSite
Remove-SPODeletedSite
Remove-SPOExternalUser
Remove-SPOGeoAdministrator
Remove-SPOHomeSite
Remove-SPOHubSiteAssociation
Remove-SPOHubToHubAssociation
Remove-SPOKnowledgeHubSite
Remove-SPOMigrationJob
Remove-SPOMultiGeoCompanyAllowedDataLocation
Remove-SPOOrgAssetsLibrary
Remove-SPOOrgNewsSite
Remove-SPOPublicCdnOrigin
Remove-SPOSdnProvider
Remove-SPOSite
Remove-SPOSiteCollectionAppCatalog
Remove-SPOSiteCollectionAppCatalogById
Remove-SPOSiteDesign
Remove-SPOSiteDesignTask
Remove-SPOSiteGroup
Remove-SPOSiteScript
Remove-SPOSiteSharingReportJob
Remove-SPOSiteUserInvitations
Remove-SPOStorageEntity
Remove-SPOTenantCdnOrigin
Remove-SPOTenantOrgRelation
Remove-SPOTenantSyncClientRestriction
Remove-SPOTheme
Remove-SPOUser
Remove-SPOUserInfo
Remove-SPOUserProfile
Repair-SPOSite
Request-SPOPersonalSite
Request-SPOUpgradeEvaluationSite
Restore-SPODataEncryptionPolicy
Restore-SPODeletedSite
Revoke-SPOHubSiteRights
Revoke-SPOSiteDesignRights
Revoke-SPOTenantServicePrincipalPermission
Revoke-SPOUserSession
Set-SPOBrowserIdleSignOut
Set-SPOBuiltInDesignPackageVisibility
Set-SPOGeoStorageQuota
Set-SPOHideDefaultThemes
Set-SPOHomeSite
Set-SPOHubSite
Set-SPOKnowledgeHubSite
Set-SPOMigrationPackageAzureSource
Set-SPOMultiGeoCompanyAllowedDataLocation
Set-SPOMultiGeoExperience
Set-SPOOrgAssetsLibrary
Set-SPOOrgNewsSite
Set-SPOSite
Set-SPOSiteDesign
Set-SPOSiteGroup
Set-SPOSiteOffice365Group
Set-SPOSiteScript
Set-SPOSiteScriptPackage
Set-SPOStorageEntity
Set-SPOStructuralNavigationCacheSiteState
Set-SPOStructuralNavigationCacheWebState
Set-SPOTenant
Set-SPOTenantCdnEnabled
Set-SPOTenantCdnPolicy
Set-SPOTenantContentTypeReplicationParameters
Set-SPOTenantSyncClientRestriction
Set-SPOTenantTaxonomyReplicationParameters
Set-SPOUnifiedGroup
Set-SPOUser
Set-SPOWebTheme
Start-SPOSiteContentMove
Start-SPOSiteRename
Start-SPOUnifiedGroupMove
Start-SPOUserAndContentMove
Stop-SPOSiteContentMove
Stop-SPOUserAndContentMove
Submit-SPOMigrationJob
Test-SPOSite
Unregister-SPOHubSite
Update-SPODataEncryptionPolicy
Update-UserType
Upgrade-SPOSite
Verify-SPOTenantOrgRelation

The client-side object model is a subset of the SharePoint Online PowerShell module (You don’t have to add a reference to CSOM assemblies – Client SDK components if you import the SharePoint PowerShell module). The SharePoint PnP PowerShell cmdlets also add significant value to this space. To install the SharePoint Online PnP PowerShell module, refer: Install SharePoint Online PnP PowerShell Module

Wrapping up

Installing the SharePoint Online PowerShell module is a simple process that can greatly enhance administrators’ productivity and streamline the management of SharePoint Online resources. By following the steps outlined in this article, administrators can easily install the module and start using its powerful capabilities to automate tasks and manage SharePoint Online. Whether you are working with a small or large SharePoint Online environment, the SharePoint Online PowerShell module provides a flexible and efficient way to manage your SharePoint Online tenant.

What is the SharePoint Online PowerShell Module?

The SharePoint Online PowerShell Module is a set of PowerShell cmdlets designed for managing and automating tasks within SharePoint Online. These cmdlets allow SharePoint Online administrator(s) to perform a wide range of administrative tasks, from site provisioning and configuration to user management and content migration.

How do I import a SharePoint Online PowerShell module?

Once the SharePoint Online PowerShell module is installed, use “Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking” to import the module to your PowerShell script.

Do I need administrative privileges to install the SharePoint Online PowerShell Module?

Yes, you need to have administrative privileges on your computer to install modules from the PowerShell Gallery. This is because the installation process writes the module to a system-wide directory.

How do I use SharePoint Online PnP PowerShell?

Once you have the SharePoint Patterns and Practices (PnP), a cross-platform PowerShell module installed, You can connect to the SharePoint Online site using cmdlet: Connect-PnPOnline -URL Your-Site-URL (instead of the SharePoint Admin center) and use any available PowerShell cmdlets from the module.
More info: Install SharePoint Online PnP PowerShell Module

What version of SharePoint Online Management Shell do I have?

To find out the SharePoint Online PowerShell module version, use: “Get-Module Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version”

Can we connect to SharePoint Online sites using PowerShell?

Of course, yes! We can connect to SharePoint Online sites using PowerShell. To get started, we need to install the SharePoint Online Management Shell and connect to SharePoint Online. For example, we can connect using Connect-SPOService -Url https://YourDomain-admin.sharepoint.com, specifying the URL of the SharePoint Online Admin site and the credentials of a user with administrative privileges. Once connected, we can use PowerShell cmdlets to manage SharePoint Online sites, such as create new sites and do the automation!

What are the system requirements for installing the SharePoint Online PowerShell Module?

The SharePoint Online PowerShell Module requires Windows PowerShell 5.1 or PowerShell 7.x and above. Additionally, it requires an internet connection to download the module from the PowerShell Gallery.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

5 thoughts on “How to Install the SharePoint Online PowerShell Module?

  • Hi, im trying to uninstall the sharepoint online module but got an error:
    When I look which one i have, i got this:
    PS C:\WINDOWS\system32> Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version

    Name Version
    —- ——-
    Microsoft.Online.SharePoint.PowerShell 16.0.24009.12000
    Microsoft.Online.SharePoint.PowerShell 16.0.23408.12000

    When I try to uninstall it, I got this:
    PS C:\WINDOWS\system32> Uninstall-Module Microsoft.Online.SharePoint.PowerShell -AllVersions
    PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names ‘Microsoft.Online.SharePoint.PowerShell’.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2194 char:21
    + … $null = PackageManagement\Uninstall-Package @PSBoundParameters
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.Power…ninstallPackage:UninstallPackage) [Uninstall-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

    Any idea?

    Reply
      • Hi Salaudeen,

        How to use PowerShell when we have FIDO key authentication(security key authentication) enabled on our service administrator ID

        Reply
  • WOW This is the best, most educational and useful site on SharePoint I’ve ever seen.

    THANKS!!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *