Modern SharePoint Online Site Inventory Reporting Using PowerShell Scripting


Hi guys, let's try to use PowerShell script to find a list of all Site Collections under a given Tenant. This way, we can determine if they are Modern or Classic for a quick inventory report.
Open the SharePoint Online Management Shell.
Run the below Script with Global/Tenant Admin credentials for complete results.
$cred = [System.Net.CredentialCache]::DefaultCredentials
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred
Connect-SPOService -Url $Tenantsite
$Results = @()
$Results += Get-SPOSite | Select-Object Url,Title,Template, @{Expression={($_.Template -like "STS#3") -or ($_.Template -like "GROUP#0") -or ($_.Template -like "SITEPAGEPUBLISHING#0")};label="Modern"} | Sort-Object @{Expression={$_.Modern};Descending=$True}, @{Expression={$_.Url};Descending=$False} | Out-File "D:\ModernSitesInventory1.csv" -Append
It uses the Microsoft.Online.SharePoint.PowerShell model to return all SharePoint Online sites using Get-SPOSite for a connected tenant and using an expression column. Then it determines whether the site is modern or not based on its template.
The list of templates (to my knowledge) that determine a modern site are:
Modern Team Site with No Office 365 Group
Modern Team Site with Connected Office 365 Group
Modern Communications Site
A good starting point is to track down the Modern/Classic sites, or just see how far spread the site experiences are across your tenant.
Happy Modern SharePointing!