Introduction to the SharePoint Online Management Shell

As a SharePoint Online admin, you can use the SharePoint Online Management Shell to run administrative commands from the command line. This introduction can help you manage users, sites, and organizations more efficiently.

In this article

What is the SharePoint Online Management Shell?

How do I get permissions and set up the environment?

SharePoint Online Management Shell cmdlet reference

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 business cmdlets. SharePoint Online Management Shell cmdlets manage SharePoint Online users and sites, whereas Office 365 for business 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 admin center or cmdlets?

If you have not used Office 365 and SharePoint Online before to administer SharePoint Online, the SharePoint Online admin center is a good place to start. For more information about the SharePoint Online admin center, see Video: Explore the SharePoint admin center or Find content about the SharePoint Online admin center.

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.

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 admin 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.

The following section contains links to cmdlet reference pages s by functionality for SharePoint Online and OneDrive.

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.

Revoke-SPOUserSession

Provides IT administrators the ability to sign out and invalidate a particular users' sessions across all their devices

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.

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.

Cmdlet

Description

Get-SPODeletedSite

Returns all deleted site collections from the Recycle Bin

Remove-SPODeletedSite

Removes a SharePoint Online deleted site collection from the Recycle Bin.

Restore-SPODeletedSite

Restores a SharePoint Online deleted site collection 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-SPOSite

Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.

Repair-SPOSite

Checks and repairs the site collection and its contents.

Set-SPOSite

Sets or updates one or more properties' values for a site collection.

Test-SPOSite

Tests a SharePoint Online site collection.

Request-SPOPersonalSite

Requests that one or more users be added to the queue for a Personal Site to be created

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.

Cmdlet

Description

Get-SPOAppErrors

Returns application errors.

Get-SPOAppInfo

Returns all installed applications.

Get-SPOTenant

Returns SharePoint Online organization properties.

Set-SPOTenant

Sets properties on the SharePoint Online organization.

Get-SPOTenantLogEntry

Retrieves SharePoint Online company logs.

Get-SPOTenantLogLastAvailableTimeInUtc

Returns the time when the SharePoint Online organization logs are collected.

Get-SPOWebTemplate

Displays all site templates that match the given identity.

Top of Page

Get-SPOTenantSyncClientRestriction

Returns the current configuration status

Remove-SPOTenantSyncClientRestriction

Disables the feature for tenancy, but does not remove any present domain GUID entries from the safe sender recipient list.

Set-SPOTenantSyncClientRestriction

Enables the feature for the tenancy and permits you to set the domain GUIDs in safe recipients list.

ConvertTo-SPOMigrationTargetedPackage

Re-maps a previously created file share based package or exported SharePoint package to accurately describe objects in a target web.

New-SPOMigrationPackage

Creates a new migration package based on source files in a local or network shared folder.

Set-SPOMigrationPackageAzureSource

Creates Azure containers, upload migration package files into the appropriate containers, and snapshot the uploaded content.

Submit-SPOMigrationJob

Submits a new migration job referenced to a previously uploaded package in Azure Blob storage into to a site collection. .

Remove-SPOMigrationJob

Removes a previously created migration job from the specified site collection.

Get-SPOMigrationJobProgress

Reports on SPO migration jobs that are in progress.

Get-SPOMigrationJobStatus

Monitors the status of a submitted SharePoint Online Migration job.

Was this information helpful?

How can we improve it?

How can we improve it?

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!