Instantly share code, notes, and snippets.

Embed
What would you like to do?
Managing Site Hub in Sharepoint Online
//Sharepoint Online - Site hub management
//Please connect first with - PS> Connect-SPOService -url https://<your tenant>-admin.sharepoint.com
//Get all sites containing url sites/mkt
Get-SPOSite -limit all | select url,ID | where-object {$_.Url -like "*sites/mkt*"}
//Remove a site from the recycle bin
Remove-SPODeletedSite -Identity https://contoso.sharepoint.com/sites/sitetoremove
//Set a site as Site hub
Set-SPOHubSite -Identity https://contoso.sharepoint.com/sites/myhubsite
//Associate one site with a Hub Site
Add-SPOHubSiteAssociation https://contoso.sharepoint.com/sites/mysite -hubsite https://contoso.sharepoint.com/sites/myhubsite
//associate multi sites into Hub SIte
$allsites = Get-SPOSite -limit all | select url,ID | where-object {$_.Url -like "*sites/mkt*"}
foreach($a in $allsites ){
Add-SPOHubSiteAssociation $a.url -HubSite https://contoso.sharepoint.com/sites/myhubsite
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment