All scripts
Microsoft 365 137

Get-SharePointHubSiteInventory

Lists every hub site in the tenant and the sites associated with each one, useful for confirming the intranet's hub and spoke structure matches what was actually planned.

Get-SharePointHubSiteInventory.ps1
<#
.SYNOPSIS
    Inventories hub sites and their associated sites.

.DESCRIPTION
    Lists every registered hub site along with the sites currently
    associated with it, so the intranet's actual hub and spoke structure
    can be compared against what was originally planned.

.EXAMPLE
    .\Get-SharePointHubSiteInventory.ps1

.NOTES
    Requires PnP.PowerShell connected to the SharePoint admin site.

.AUTHOR
    Shehryar Hassan
#>

$hubs = Get-PnPHubSite
$allSites = Get-PnPTenantSite

$report = foreach ($hub in $hubs) {
    $associated = $allSites | Where-Object { $_.HubSiteId -eq $hub.ID }
    [pscustomobject]@{
        HubTitle        = $hub.Title
        HubUrl          = $hub.SiteUrl
        AssociatedCount = $associated.Count
        AssociatedSites = ($associated.Url -join "; ")
    }
}

$report | Format-Table HubTitle, HubUrl, AssociatedCount -AutoSize

Read it before you run it, and test in a safe tenant first.