September 22, 2021

Most Useful PowerShell Cmdlets to Manage SharePoint Online Efficiently

by Kathy Cooper

4 min read

No Comments

Managing and reporting SharePoint Online using PowerShell is more convenient when compared to the admin center. This blog lists the top SharePoint Online PowerShell cmdlets to know about your SPO environment in detail.

Getting Started with SharePoint Online PowerShell

To use SharePoint Online PowerShell cmdlets,

Connect to SharePoint Online PowerShell

To manage the SharePoint Online environment through PowerShell, you need to create a PowerShell session using the below cmdlet.

If your tenant is, you can use ‘contoso’ as the HostName. For eg,

Note: Instead of manually installing and connecting SharePoint Online, you can use the pre-built PowerShell script to connect Office 365 services. You can also use this script to connect various Office 365 services like Azure AD, Exchange Online, Teams, Security & Compliance center, etc.

Get All SharePoint Online Site Collections

To view all the site collections in SharePoint Online, run the below cmdlet.

To get all the properties of a site, you can run the Get-SPOSite cmdlet along with the site identity.

View All Users in the Site Collection

To get all the SharePoint Online users and security group accounts in the specific SharePoint site, execute the below cmdlet.

You can use the ‘where’ condition to retrieve either user or security group accounts.

The above example returns all the users in the site collection.

Find All External Users in SharePoint Online

SharePoint admins follow different approaches to retrieve SharePoint Online external users. The conventional method is shown below.

By using the Get-SPOExternalUser cmdlet, you can retrieve 50 users by default. To retrieve all users, you need to run the cmdlet with incremented ‘Position’ Value.

To view external users in the specific site, run the cmdlet with SiteURL.

This example returns the first 30 users that match the SiteURL

To get detailed information on external users, you can generate the SharePoint Online external users report.

List Deleted Sites Using PowerShell

The Get-SPODeletedSite cmdlet returns all the deleted site collections from the recycle bin.

The above cmdlet lists all the deleted sites and site collection except personal sites. To include personal sites, run the cmdlet as follows.

The result includes site URL, deletion time, days remaining to restore the site, etc. You can use an audit log search to find out who deleted the site collection.

If you want to restore the deleted SharePoint site, you can use the Restore-SPODeletedSite as shown below.

Get SharePoint Online Tenant Settings

By using the Get-SPOTenant cmdlet, you can view organization-level site collection properties.

The above cmdlet returns SPO organization properties like StorageQuota, ResourceQuota, SharingCapability, SiteCreationMode, etc.

Find SharePoint Sites Linked with Private Channels

When a private channel is created in Microsoft Teams, it creates a SharePoint site automatically. To identify SharePoint sites created as a result of private channels, run the following cmdlet.

The template value “TEAMCHANNEL#0” denotes the site collection provisioned for each Teams private channel.

We have listed few SharePoint Online template IDs below:

STS#0 – Shows classic Teams sites

STS#3 – Lists Teams sites that has no connection to the Office 365 group

Group#0 – Retrieves Office 365 group associated Teams sites

Note: When a team is created, a Microsoft 365 group is generated. Each Microsoft 365 group creates a SharePoint site to store the shared documents. You can download our dedicated script to identify Teams and their SharePoint site URL.

Challenges in Managing SharePoint Online with PowerShell

SharePoint Online integrates multiple Office 365 components like Microsoft 365 groups, Teams, Private Channels, One Drive for Business, etc. So, the SharePoint Online PowerShell module alone is insufficient to generate all the SPO reports.

  • It requires juggling multiple Office 365 PowerShell modules.
  • For auditing SharePoint Online, you need to create an Exchange Online PowerShell session to use the Search-UnifiedAuditLog cmdlet.
  • Sending a report by email is one of the tedious tasks.

What if all the PowerShell challenges can be solved with just a few mouse clicks? Isn’t it cool?

AdminDroid Microsoft 365 reporting tool provides 100+ SharePoint Online reports along with visually appealing dashboards to know your SharePoint Online environment in a better way.

SharePoint Online Reporting dashboard SharePoint Online reporting tool

SharePoint Online auditing tool

SharePoint Online reporting and auditing tool

Additionally, AdminDroid offers 1500+ pre-built reports and 20 visually appealing dashboards to understand your Microsoft 365 organization at a glance. By using the ‘Views’ and ‘Advanced Filter’ options, you can create custom reports based on your requirement.

Additionally, AdminDroid offers 100+ reports and a handful of dashboards as free to manage your organization’s users, licenses, groups, group membership, membership changes, user logins, password changes, etc. The free version allows you to perform customization, scheduling and exporting too. Download Free Office 365 reporting tool by AdminDroid and see how it works for you.

I hope this blog will help you in managing and reporting SharePoint Online environment. Which method do you prefer to generate reports? Share your thoughts through the comment section.

Share article