SharePoint Online Management Shell is very useful for administrators in managing their SharePoint Online environments. It provides a set of PowerShell cmdlets that allow users to control various aspects of SharePoint sites and settings in Microsoft 365. It saves time and effort by automating tasks requiring manual input through the web interface.
The SharePoint Online Management Shell enables users to perform bulk operations, manage site collections, and configure SharePoint settings using simple PowerShell commands. It’s especially useful for large-scale changes or repetitive tasks across multiple sites. Administrators can easily create, modify, or delete site collections, manage user permissions, and configure SharePoint features.
To get started, users need to download and install the SharePoint Online Management Shell from the Microsoft website or PowerShell Gallery. Once installed, they can connect to their SharePoint Online tenant using their admin credentials. Let us discuss everything about the SharePoint Online management shell.
Overview of SharePoint Online Management Shell
SharePoint Online Management Shell is a powerful tool for managing SharePoint settings. It uses PowerShell cmdlets to control SharePoint at the organization and site collection levels.
Key Features of SharePoint Online Management Shell
SharePoint Online Management Shell offers remote management of SharePoint settings. It allows administrators to perform tasks quickly and efficiently. The shell can manage user profiles, site collections, and tenant settings.
It supports bulk operations, saving time on large-scale changes. Administrators can create scripts to automate routine tasks. This feature helps manage multiple sites or users at once.
The shell provides access to features not available in the SharePoint admin center. It offers more control over SharePoint Online environments. Administrators can customize their management approach using PowerShell scripts.
Understanding Cmdlets in PowerShell
Cmdlets are special commands in PowerShell that are used to perform specific tasks. In SharePoint Online Management Shell, cmdlets follow a verb-noun structure. For example, “Get-SPOSite” retrieves information about a site collection.
Common verbs in SharePoint cmdlets include:
- Get: Retrieves information
- Set: Changes settings
- New: Creates new items
- Remove: Deletes items
Each cmdlet has parameters that refine its action. Administrators can combine cmdlets to create complex management scripts. This flexibility allows for precise control over SharePoint Online environments.
Comparison with SharePoint Server Management Shell
SharePoint Online Management Shell differs from its on-premises counterpart. The online version is installed on the administrator’s local machine. SharePoint Server Management Shell runs on the server hosting SharePoint.
Online shell focuses on cloud-based SharePoint tasks. It doesn’t include cmdlets for server-specific operations. The online version updates more frequently, adding new features for Office 365 management.
SharePoint Server shell offers more control over the physical server setup. It includes cmdlets for managing farm configuration and services. The online shell is simpler, as Microsoft handles the underlying infrastructure.
Once you install SharePoint in a SharePoint On-Premises server, PowerShell cmdlets are available in the SharePoint management shell. You need not install additional things to work on PowerShell SharePoint on-premise.
In a SharePoint server, all PowerShell SharePoint cmdlets are available in Microsoft.SharePoint.PowerShell.dll.
If you are not using SharePoint management shell, using Windows PowerShell ISE, then you have to manually register Microsoft.SharePoint.PowerShell.dll module for SharePoint Server cmdlets. You can do this by adding the below line at the beginning of a PowerShell file.
Add-PSSnapin Microsoft.SharePoint.PowerShell
You can also add the below lines.
$snap = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.PowerShell'}
if ($snap -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
To work with PowerShell SharePoint On-Premises, the account you are using should have securityadmin server role membership in SQL Server. The account should also be a member of the Administrators group.
Remember, the account you used while installing the SharePoint server is provided with proper permissions to run or execute PowerShell cmdlets in the SharePoint server.
Note: Always use Open SharePoint management shell or PowerShell ISE as Run as administrator.
Check out SharePoint Site Owner
Setting Up the PowerShell Environment
Getting started with SharePoint Online Management Shell requires a few key steps. These include installing the tool, connecting to your SharePoint environment, and meeting the system requirements.
Installing SharePoint Online Management Shell
To install SharePoint Online Management Shell, open Windows PowerShell as an administrator. Run this command:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
This will download and set up the module on your computer.
To keep the module up to date, run:
Update-Module -Name Microsoft.Online.SharePoint.PowerShell
Updating ensures you have access to all the latest features and bug fixes.
There is another way to install it. You can also download and install SharePoint Online management shell.
Unlike Windows PowerShell ISE, the SharePoint Online management shell will not be available in your system by default.
Note: You do not need SharePoint to be installed in your system to work with the SharePoint Online management shell.
First, download SharePoint Online Management Shell from this MSDN URL. Choose the language and click on Download.
Then, it will ask to download either the 64-bit or 32-bit versions. Choose the 64-bit version and click Next to download the MSI file.
Now double-click on the MSI file and click on Run like below:
Then, in the SharePoint Online Management Shell Setup, accept the license agreement and click Install.
Then the installation will progress like below:
Once the installation is over, it will show the Installation completion wizard like below:
This is how to download and install the SharePoint Online management shell.
Check out SharePoint List Items CRUD Operations Using PnP PowerShell
Connect to SharePoint Online from SharePoint Online Management Shell
After installation, you need to connect to your SharePoint Online environment. Use the Connect-SPOService cmdlet:
Connect-SPOService -Url https://yourtenant-admin.sharepoint.com
Replace “yourtenant” with your actual SharePoint domain name.
You’ll be asked to enter your admin credentials. If you use multi-factor authentication, you may need extra steps to connect securely.
Connect-SPOService -Url https://onlysharepoint2013-admin.sharepoint.com -credential bijay@onlysharepoint2013.onmicrosoft.com
If you do not provide the SharePoint Online admin site URL, you will get an error like the one below:
Then it will ask for your credentials like below:
Once it is connected successfully, we can run SharePoint online PowerShell cmdlets.
Once connected, you can run various commands to manage your SharePoint sites and settings.
Windows PowerShell Module Requirements
To use SharePoint Online Management Shell, you need:
- Windows 10 or later
- Windows PowerShell version 5.1 or higher
Make sure your system meets these requirements before installing the module.
You also need admin rights for your Microsoft 365 account to use most of the cmdlets.
Check your PowerShell version by running:
$PSVersionTable.PSVersion
If needed, update PowerShell through the Microsoft Store or download it from the official website.
Check out How to Share SharePoint Site with External Users?
SharePoint Online Management Shell Cmdlets
SharePoint Online Management Shell provides many useful commands for managing SharePoint sites and services. These commands help administrators perform tasks quickly and efficiently.
Some key commands include:
- Connect-SPOService: Connects to a SharePoint Online administration center
- Get-SPOSite: Retrieves information about site collections
- New-SPOSite: Creates a new site collection
- Set-SPOSite: Changes settings for an existing site collection
- Remove-SPOSite: Deletes a site collection
- Get-SPOUser: Gets information about a specific user
- Add-SPOUser: Adds a user to a site collection
- Set-SPOUser: Changes a user’s properties
Administrators can also manage hub sites with commands like:
- Register-SPOHubSite: Registers a site as a hub site
- Get-SPOHubSite: Gets information about hub sites
- Add-SPOHubSiteAssociation: Associates a site with a hub site
- Remove-SPOHubSiteAssociation: Removes a site’s association with a hub site
Other useful commands include:
- Get-SPOTenant: Retrieves SharePoint Online organization properties
- Set-SPOTenant: Updates SharePoint Online organization properties
- Add-SPOTheme: Creates a custom theme
- Get-SPOTheme: Gets information about available themes
- Set-SPOWebTheme: Applies a theme to a site
Administrators can manage the Content Delivery Network (CDN) with:
- Get-SPOTenantCdnEnabled: Checks if the CDN is enabled
- Set-SPOTenantCdnEnabled: Enables or disables the CDN
- Add-SPOTenantCdnOrigin: Adds a CDN origin
For user management across geographic locations:
- Get-SPOCrossGeoMovedUsers: Lists users moved between geo locations
- Get-SPOGeoStorageQuota: Retrieves geolocation storage quota information
- Set-SPOGeoStorageQuota: Sets storage quota for a geolocation
These commands allow administrators to efficiently manage various aspects of SharePoint Online, from site creation and user management to theme application and CDN configuration.
You can also display all the available commands in SharePoint Online management shell, like below:
Get-Command *-SPO*
Once you run the commands, you can see the output below:
- Add-SPOGeoAdministrator
- Add-SPOHubSiteAssociation
- Add-SPOSiteCollectionAppCatalog
- Add-SPOSiteDesign
- Add-SPOSiteScript
- Add-SPOTenantCdnOrigin
- Add-SPOTheme
- Add-SPOUser
- Approve-SPOTenantServicePrincipalPermissionReques
- Connect-SPOService
- ConvertTo-SPOMigrationEncryptedPackage
- ConvertTo-SPOMigrationTargetedPackage
- Deny-SPOTenantServicePrincipalPermissionRequest
- Disable-SPOTenantServicePrincipal
- Disconnect-SPOService
- Enable-SPOTenantServicePrincipal
- Get-SPOAppErrors
- Get-SPOAppInfo
- Get-SPOBrowserIdleSignOut
- Get-SPOCrossGeoMovedUsers
- Get-SPOCrossGeoMoveReport
- Get-SPOCrossGeoUsers
- Get-SPODataEncryptionPolicy
- Get-SPODeletedSite
- Get-SPOExternalUser
- Get-SPOGeoAdministrator
- Get-SPOGeoMoveCrossCompatibilityStatus
- Get-SPOGeoStorageQuota
- Get-SPOHideDefaultThemes
- Get-SPOHubSite
- Get-SPOMigrationJobProgress
- Get-SPOMigrationJobStatus
- Get-SPOMultiGeoCompanyAllowedDataLocation
- Get-SPOMultiGeoExperience
- Get-SPOPublicCdnOrigins
- Get-SPOSite
- Get-SPOSiteContentMoveState
- Get-SPOSiteDataEncryptionPolicy
- Get-SPOSiteDesign
- Get-SPOSiteDesignRights
- Get-SPOSiteGroup
- Get-SPOSiteScript
- Get-SPOStorageEntity
- Get-SPOTenant
- Get-SPOTenantCdnEnabled
- Get-SPOTenantCdnOrigins
- Get-SPOTenantCdnPolicies
- Get-SPOTenantContentTypeReplicationParameters
- Get-SPOTenantLogEntry
- Get-SPOTenantLogLastAvailableTimeInUtc
- Get-SPOTenantServicePrincipalPermissionGrants
- Get-SPOTenantServicePrincipalPermissionRequests
- Get-SPOTenantSyncClientRestriction
- Get-SPOTenantTaxonomyReplicationParameters
- Get-SPOUnifiedGroup
- Get-SPOUser
- Get-SPOUserAndContentMoveState
- Get-SPOUserOneDriveLocation
- Get-SPOWebTemplate
- Grant-SPOHubSiteRights
- Grant-SPOSiteDesignRights
- Invoke-SPOMigrationEncryptUploadSubmit
- Invoke-SPOSiteDesign
- New-SPOMigrationEncryptionParameters
- New-SPOMigrationPackage
- New-SPOPublicCdnOrigin
- New-SPOSdnProvider
- New-SPOSite
- New-SPOSiteGroup
- Register-SPODataEncryptionPolicy
- Register-SPOHubSite
- Remove-SPODeletedSite
- Remove-SPOExternalUser
- Remove-SPOGeoAdministrator
- Remove-SPOHubSiteAssociation
- Remove-SPOMigrationJob
- Remove-SPOMultiGeoCompanyAllowedDataLocation
- Remove-SPOPublicCdnOrigin
- Remove-SPOSdnProvider
- Remove-SPOSite
- Remove-SPOSiteCollectionAppCatalog
- Remove-SPOSiteCollectionAppCatalogById
- Remove-SPOSiteDesign
- Remove-SPOSiteGroup
- Remove-SPOSiteScript
- Remove-SPOStorageEntity
- Remove-SPOTenantCdnOrigin
- Remove-SPOTenantSyncClientRestriction
- Remove-SPOTheme
- Remove-SPOUser
- Repair-SPOSite
- Request-SPOPersonalSite
- Request-SPOUpgradeEvaluationSite
- Restore-SPODataEncryptionPolicy
- Restore-SPODeletedSite
- Revoke-SPOHubSiteRights
- Revoke-SPOSiteDesignRights
- Revoke-SPOTenantServicePrincipalPermission
- Revoke-SPOUserSession
- Set-SPOBrowserIdleSignOut
- Set-SPOGeoStorageQuota
- Set-SPOHideDefaultThemes
- Set-SPOHubSite
- Set-SPOMigrationPackageAzureSource
- Set-SPOMultiGeoCompanyAllowedDataLocation
- Set-SPOMultiGeoExperience
- Set-SPOSite
- Set-SPOSiteDesign
- Set-SPOSiteGroup
- Set-SPOSiteOffice365Group
- Set-SPOSiteScript
- Set-SPOStorageEntity
- Set-SPOTenant
- Set-SPOTenantCdnEnabled
- Set-SPOTenantCdnPolicy
- Set-SPOTenantContentTypeReplicationParameters
- Set-SPOTenantSyncClientRestriction
- Set-SPOTenantTaxonomyReplicationParameters
- Set-SPOUnifiedGroup
- Set-SPOUser
- Set-SPOWebTheme
- Start-SPOSiteContentMove
- Start-SPOUserAndContentMove
- Stop-SPOUserAndContentMove
- Submit-SPOMigrationJob
- Test-SPOSite
- Unregister-SPOHubSite
- Update-SPODataEncryptionPolicy
- Upgrade-SPOSite
Check out Create and Delete SharePoint Document Library Using PowerShell?
SharePoint Management Shell Examples
Now, here are a few examples of using SharePoint Online management shell.
Create New Site Collections
To create a new site collection, use the New-SPOSite cmdlet. This command allows you to specify important details like the URL, owner, and template. Here’s an example:
New-SPOSite -Url "https://contoso.sharepoint.com/sites/newsite" -Owner "user@contoso.com" -Template "STS#0"
You can also set storage quotas and time zones during creation. For batch creation of multiple sites, administrators can use a CSV file with site details and loop through it.
Configure Site Settings
The Set-SPOSite cmdlet helps change various site settings. Admins can modify sharing capabilities, storage limits, and other properties. For example:
Set-SPOSite -Identity "https://contoso.sharepoint.com/sites/site1" -SharingCapability Disabled
This command disables sharing for the specified site. Other useful settings include changing the site logo, adjusting the time zone, or setting content types.
Manage Site Collection Administrators
To add or remove site collection admins, use the Set-SPOUser cmdlet. This allows for quick updates to site permissions. Here’s how to add an admin:
Set-SPOUser -Site "https://contoso.sharepoint.com/sites/site1" -LoginName "user@contoso.com" -IsSiteCollectionAdmin $true
For viewing current admins, the Get-SPOUser cmdlet is helpful. It lists all users with their roles for a given site.
Perform Batch Operations
Batch operations save time when managing multiple sites. The SharePoint Online Management Shell allows for looping through site collections to apply changes. For example, to update settings across all sites:
Get-SPOSite | ForEach-Object {
Set-SPOSite -Identity $_.Url -SharingCapability ExternalUserSharingOnly
}
This script changes sharing settings for all sites. Admins can also use similar loops for tasks like adding hub associations or updating site designs across multiple site collections.
Conclusion
SharePoint Online Management Shell is a powerful tool for administrators. Users can easily manage sites, users, and content with its wide range of cmdlets.
I have explained here how to download and install SharePoint Online management shell and work with SharePoint management shell with a few examples. Do let me know in the comment below if this tutorial helps you.
You may also like:
- Difference Between Team Site And Communication Site In SharePoint
- How to Create a SharePoint Online Site Using Power Automate
- Install PnP PowerShell for SharePoint Online
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com