As a SharePoint Online admin, you can use the SharePoint Online Management Shell to run administrative commands from the command line. This can help you manage users, sites, and organizations more efficiently.
In this article
What is the SharePoint Online Management Shell?
SharePoint Online Management Shell is a Windows PowerShell module. You can use it to manage SharePoint Online users, sites, site collections, and organizations from the command line, instead of using the SharePoint Administration Center user interface. Windows PowerShell enables you to perform these command-line operations by using a custom command called a cmdlet. A cmdlet, pronounced "command-let," is constructed as a verb-noun pair, such as Get-Command. The two parts of a cmdlet are separated by a hyphen (-) without spaces. The verb part refers to the action that the cmdlet takes. The noun part refers to the object on which the cmdlet takes action. Cmdlets are especially efficient for batch operations — for example, adding hundreds of new SharePoint Online users.
Note You can use the Get-Command cmdlet to list all cmdlets, and use the Get-Help cmdlet to learn more about any cmdlet. For more information, see Get-Command and Get-Help.
How do I use the Windows PowerShell Command Builder?
The Windows PowerShell Command Builder Tool helps you quickly understand and use Windows PowerShell cmdlets for SharePoint Online. Suppose that you want to create a site. By using the Command Builder tool to create a cmdlet, you can create a site from the command line, instead of stepping through several pages in the user Interface. To use the tool, you just choose a verb, such as Add. The tool then filters the cmdlets that begin with that verb and shows you nouns that you can use with the specified verb, such as Site.
You can download the Command Builder tool and install it on your desktop. For more information, see Windows PowerShell Command Builder Getting Started Guide.
What is the difference between SharePoint Online cmdlets and Office 365 cmdlets?
The set of SharePoint Online Management Shell cmdlets differs from the set of Office 365 for professionals and small businesses cmdlets. SharePoint Online Management Shell cmdlets manage SharePoint Online users and sites, whereas Office 365 cmdlets manage Office 365 level tasks such as domain, license, organization information, and services. They both manage users and groups. However, Office 365 users and groups apply not only to SharePoint Online services, but also to Exchange Online and Lync Online Services.
Should I use the SharePoint Online Administration Center or cmdlets?
If you have not used Office 365 and SharePoint Online before to administer SharePoint Online, the SharePoint Online Administration Center is a good place to start. For more information about the SharePoint Online Administration Center, see SharePoint Admin Center Help.
After you become familiar with SharePoint Online features and technologies, just use Windows PowerShell cmdlets. Especially when you want to manage many SharePoint Online users, sites, or site collections, SharePoint Online Management Shell cmdlets are the choice.
Top of Page
How do I get permissions and set up the environment?
Get permissions
To run the SharePoint Online Management Shell cmdlets, you have to be a SharePoint Online global administrator.
Note To use cmdlets, a SharePoint Online site administrator must be a global administrator in Office 365.
Set up the environment
Before you can run cmdlets, you have to set up the SharePoint Online Management Shell environment and connect to the service. For more information, see Set up the SharePoint Online Management Shell environment.
After you set up the environment, you have to run Connect-SPOService before you can manage the users and site collections. If you have not run Connect-SPOService yet, you will receive an error message that no connection is available. Suppose that you want to connect to the SharePoint Online Administration Center for Contoso.com and your user name is admin@contoso.com. To connect, you just run the following command:
Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential admin@contoso.com.
Top of Page
SharePoint Online Management Shell cmdlet reference
The following articles list cmdlets for SharePoint Online by functionality.
User management cmdlets
| Cmdlet |
Description |
| Add-SPOUser |
Adds an existing Office 365 user or an Office 365 security group to a SharePoint group. |
| Get-SPOUser |
Returns the SharePoint Online user or security group accounts that match a given search criteria. |
| Remove-SPOUser |
Removes a user or a security group from a site collection or a group. |
| Set-SPOUser |
Configures properties on an existing user. |
| Get-SPOExternalUser |
Returns external users that are located in the tenant's folder based on specified criteria. |
| Remove-SPOExternalUser |
Permanently removes a collection of external users from the tenant’s folder. |
Top of Page
User group management cmdlets
| Cmdlet |
Description |
| Get-SPOSiteGroup |
Gets all the groups on the specified site collection. |
| New-SPOSiteGroup |
Creates a new group in a SharePoint Online site collection. |
| Remove-SPOSiteGroup |
Removes a SharePoint Online group from a site collection. |
| Set-SPOSiteGroup |
Updates the SharePoint Online owner and permission levels on a group inside a site collection. |
Top of Page
Upgrade cmdlets
| Cmdlet |
Description |
| Upgrade-SPOSite |
Starts the upgrade process on a site collection. |
| Request-SPOUpgradeEvaluationSite |
Requests creation of a copy of an existing site collection for the purposes of validating the effects of upgrade without affecting the original site. |
Top of Page
Site collection management cmdlets
| Cmdlet |
Description |
| Get-SPODeletedSite |
Returns all deleted site collections from the Recycle Bin |
| Get-SPOSite |
Returns one or more site collections. |
| New-SPOSite |
Creates a new SharePoint Online site collection for the current company. |
| Remove-SPODeletedSite |
Removes a SharePoint Online deleted site collection from the Recycle Bin. |
| Remove-SPOSite |
Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin. |
| Repair-SPOSite |
Checks and repairs the site collection and its contents. |
| Restore-SPODeletedSite |
Restores a SharePoint Online deleted site collection from the Recycle Bin. |
| Set-SPOSite |
Sets or updates one or more properties' values for a site collection. |
| Test-SPOSite |
Tests a SharePoint Online site collection. |
Top of Page
Service connection and disconnection cmdlets
| Cmdlet |
Description |
| Connect-SPOService |
Connects a SharePoint Online global administrator to a SharePoint Online connection; that is, connects the administrator to the SharePoint Online Administration Center.
This cmdlet must be run before any other SharePoint Online cmdlets can run. |
| Disconnect-SPOService |
Disconnects from a SharePoint Online service. |
Organization-level monitoring and management cmdlets
Top of Page