sharepoint online management shell cover

Using PowerShell Commands for SharePoint Online Management Shell


Most SharePoint administration functions are performed through the graphical portal interface. However, if you frequently perform the same tasks, you can automate them using PowerShell. Administrators can use PowerShell to manage various tasks in SharePoint. Microsoft provides separate sets of cmdlets for managing on-premises SharePoint and SharePoint Online. The number of PowerShell cmdlets for SharePoint Online is less than for the on-premises version of SharePoint.

Installing SharePoint Online Management Shell

To connect to SharePoint Online, you need to install SharePoint Online Management Shell. This PowerShell module allows you to manage SharePoint Online subscription in the Office 365. To install this module, PowerShell 3.0 (included in Windows Management Framework 3.0) must be installed on your computer. Download SharePoint Online Management Shell here:

https://www.microsoft.com/en-US/download/details.aspx?id=35588

Depending on your OS, you need to download 32 or 64 bit MSI distribution.

sharepoint online management shell

Installation of the module is quite simple. Just follow the instructions of the installation wizard.

sharepoint online management shell setup

After the installation is complete, you can start the SharePoint Online Management Shell from the Start menu, or import the SharePoint PowerShell module into your PoSh session:

Import-Module Microsoft.Online.SharePoint.PowerShell

sharepoint online management shell windows 10

SharePoint Online Management Shell Commands

A complete list of available commands of the module Microsoft.Online.SharePoint.PowerShell.dll can be displayed in the way like this:

Get-Command –Module Microsoft.Online.SharePoint.PowerShell

Alternatively, you can display all available SharePoint Online cmdlets using the command:

Get-Command *-SPO*

sharepoint online management shell commands

The most frequently used cmdlets are listed below:

  • Add-SPOUser
  • Connect-SPOService
  • Disconnect-SPOService
  • Get-SPOExternalUser
  • Get-SPOSite
  • Get-SPOSiteGroup
  • Get-SPOTenant
  • Get-SPOUser
  • New-SPOSite
  • New-SPOSiteGroup
  • Remove-SPOSite
  • Remove-SPOSiteGroup
  • Remove-SPOUser
  • Set-SPOUser
  • Set-SPOUser
  • Test-SPOSite
  • Upgrade-SPOSite

Now you can connect to SharePoint using the Connect-SPOService cmdlet. If you are connecting to SharePoint Online, you need to specify the tenant URL and admin account name.

Connect-SPOService –Url https://theitbrostenant.sharepoint.com –Credential admin@theitbrostenant.onmicrosoft.com

You can check the version of SharePoint as follows:

Get-SPFarm | Select BuildVersion

To list all site collection use the Get-SPOSite cmdlet.

sharepoint online management shell console

Using the Get-Member cmdlet, you can define the properties and methods of any object. For example, using the following command you can see all the properties of the SPSite object:

Get-SPSite | Get-Member

To remove a site collection, use the Remove-SPOSite cmdlet

Remove-SPOSite -Identity theitbrostenant.sharepoint.com/sites/SiteCollectionName –NoWait

To create multiple sites from a CSV file in the following format:

Name,URL,Owner,StorageQuota,ResourceQuota,Template
First Site,https://theitbrostenant.sharepoint.com/sites/site1,user1@theitbros.com,1024,300,STS#0
Corporate Blog, https://theitbrostenant.sharepoint.com/sites/blog,user2@theitbros.com,512,100,BLOG#0

Use the following script:

Import-Csv .\SitesToAdd.csv| % {New-SPOSite -Owner $_.Owner -StorageQuota $_.StorageQuota -Url $_.Url -NoWait -ResourceQuota $_.ResourceQuota -Template $_.Template -Title $_.Name}

Get the list of groups:

Get-SPOSite | ForEach-Object {Get-SPOSiteGroup -Site $_.Url} |Format-Table

Get a list of all users:

Get-SPOSite | ForEach-Object {Get-SPOUser -Site $_.Url}

Add new Site Collection administrator:

Set-SPOUser -Site {Corporate Blog} -LoginName root@theitbros.com -IsSiteCollectionAdmin $true

To remove a user from the Site Collection Administrator group:

Remove-SPOUser -LoginName root@theitbros.com -Site {Corporate Blog}

Available templates can be viewed with the command:

Get-SPWebTemplate

List of installed components:

Get-SPFeature -Limit ALL | Where-Object {$_.Scope -eq "SITE"}

List of available site templates:

Get-SPWebTemplate | where {$_.Title -match "business"}

List of running SharePoint services:

Get-Service | Where-Object {$_.DisplayName -like "Sharep*"}

Check the content database for errors:

Test-SPContentDatabase -name WSS_Content –webapplication http://blog

You may also like:

Add Calendar Permissions in Office 365 via Powersh... This is a tutorial on how to add calendar permissions in Office 365 for your users via Powershell. You can add permissions onto a specific mailbox, or...
Removing Old and Unused Drivers from Driver Store ... Each time you install or update your device driver, Windows OS (since Vista) continues to store the old version of the driver in the system Driver Sto...
How to copy files with BITS using PowerShell If you use local (and global) networks, you might know that files between systems are transferring by using SMB, FTP or HTTP protocols. The problem wi...
How to transfer FSMO Roles From a Failed Domain Co... In case domain controller, which owns FSMO (Flexible Single Master Operation) roles, is fail (virus attack, fatal software problems or catastrophic ha...
LZX — new Windows 10 NTFS compression algorithm Many of you may know that NTFS file system used by Windows 10 already has a built-in NTFS compression feature. But in Windows 10 Microsoft has added c...

Add Your Comment