1

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

3

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
Get-SPOHubSite

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

$hubSiteId="9067810e-81f3-4798-a7b6-9d0b5daf25ce"
$sites = Get-SPOSite -Limit ALL 
foreach ($site in $sites) {
    $siteDetailed = Get-SPOSite -Detailed $site.Url
    if($siteDetailed.HubSiteId -eq $hubSiteId){
        $site.Url
    }
}

Your Answer

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

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