Get all sites associated with a SharePoint Online Hub Site

Connect-PnPOnline -Url https://[tenant]

# get the hub site id
$hubSite = Get-PnPTenantSite "https://[tenant]"
$hubSiteId = $hubSite.HubSiteId

# get all sites associated to the hub
$sites = Get-PnPTenantSite -Detailed
$sites | select url | % { 
  $s = Get-PnPTenantSite $_.url 
  if($s.hubsiteid -eq $hubSiteId){
    write-host $s.url

I couldn’t get the HubSiteId through normal iterating over the $sites collection. So I ended up getting the sites explicitly.

If you found a simpler approach, let me know!


  • Kai

    Hello you! My name is Kai Boschung and I live with my girl Dominique and our dog Nikita close to Bern, Switzerland.I work at Experts Inside and founded together with compadres the IoT consulting firm appery.

1 Comment

Add Yours

When you join a team site or communication site under a hub site, the site inherits the look and feel, theme, and logo from the hub site level. All of the joined team sites and communication sites will have the same consistent look and feel.

Leave a Reply