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!