I am trying to disassociate all of my sites with my hub site and then associate them all again so that I can force an update of the styling. I know the code to remove an association and then create an association however I haven't been able to find any code to iterate through each site. There are no sub-sites and each site is found on https://.sharepoint.com/sites/ .

Thanks :)

1 Answer 1


We can download the SharePoint Online Management Shell.

And connect SharePoint online admin site and get the hub sites using the PowerShell below.

connect-SPOService -Url https://xxx-admin.sharepoint.com

And get all the sites associated hub site base on the sub site Id.

$sites = Get-SPOSite -Limit ALL 
foreach ($site in $sites) {
    $siteDetailed = Get-SPOSite -Detailed $site.Url
    if($siteDetailed.HubSiteId -eq $hubSiteId){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.