Get all sites associated with a SharePoint Online Hub Site – Engineerer
234
post-template-default,single,single-post,postid-234,single-format-standard,wp-custom-logo,bridge-core-3.1.2,qode-page-transition-enabled,ajax_fade,page_not_loaded,,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-30.1,qode-theme-bridge,qode_header_in_grid,elementor-default,elementor-template-full-width,elementor-kit-641,elementor-page-1064
Network

Get all sites associated with a SharePoint Online Hub Site

Connect-PnPOnline -Url https://[tenant]-admin.sharepoint.com

# get the hub site id
$hubSite = Get-PnPTenantSite "https://[tenant].sharepoint.com/sites/intranet"
$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!