In this SharePoint Online and PowerShell blog post, we will learn how to list all the active SharePoint Online sites and the size of each one using PowerShell.
Install SharePoint Online PowerShell Module
Before we start, we need to install the SharePoint Online PowerShell module, which only works on a Windows machine with PowerShell 5.1.
Note: SharePoint Online PowerShell module doesn’t work on Linux or macOS with PowerShell 7.
To install the module, run the following command on a PowerShell 5.1 console.
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Connect to SharePoint Online using PowerShell
Now, let go ahead and connect to our SharePoint Online administration site using PowerShell. For this step, you will need to know your tenant name.
Run the following command using your tenant name (Change YOURTENANTNAME with your real M365 tenant name)
Connect-SPOService -Url https://YOURTENANTNAE-admin.sharepoint.com
List All Sites and Size
We are ready to run or cmdlet and generate a report of all our sites and sizes at this stage.
Get-SPOSite | select title, StorageUsageCurrent, url | ft -autosize
If you would like to get all the details of an individual site, run the following cmdlet with the site’s URL.
Get-SPOSite -Identity https://yourtenat.sharepoint.com/sites/hr -Detailed | fl