I was playing around with SharePoint Online Hub Sites today and noticed something interesting…

You might be asking yourself what are Hub Sites?! Read all about them here: https://techcommunity.microsoft.com/t5/SharePoint-Blog/Organize-your-intranet-with-SharePoint-hub-sites/ba-p/174081 

Note: As of 5/7/2018 Hub Sites are at 100% WW roll out to Office 365 per https://twitter.com/SharePoint/status/993509237002190848 

In my Office 365/SharePoint Online tenant I created 2 hub sites and associated a few brand new team sites to each hub. (Read more about creating hub sites here: https://support.office.com/en-us/article/create-a-hub-site-in-sharepoint-online-92bea781-15d8-4bda-805c-e441e2191ff3?ui=en-US&rs=en-US&ad=US)

Navigation/branding was propagating to all sites in each hub, but I was curious on how to take an inventory of all these sites (which sites are associated to which hub). I dug open the SharePoint Online Management Shell and did a Get-Member against Get-SPOSite. There are 2 new values – IsHubSite and HubSiteId


(As of 5/8/2018) I cannot run a simple Get-SPOSite | Select Url, IsHubSite, HubSiteId (This may work down the road, but does not work at this time). It displays false for IsHubSite for each site and displays all zeros for each HubSiteId

Connecting to each SPOSite individually works through (You can also run Get-SPOHubSite to see only the Hub Sites in the tenant):

I came up with the following script to loop through all SharePoint Online Site Collections and display the URL, Whether or not it is a hub site, and what the hub site ID is. This could be expanded upon, but is something to get you started and get accurate counts of how many hub sites are in the tenant and how many/which child sites are associated with each hub:

Screenshot for proof:

Hope this helps!