SOLVED

Find all SharePoint sites associated with a hub site

%3CLINGO-SUB%20id%3D%22lingo-sub-922219%22%20slang%3D%22en-US%22%3EFind%20all%20SharePoint%20sites%20associated%20with%20a%20hub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-922219%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20sure%20this%20question%20might%20have%20been%20answered%20already%2C%20but%20I%20couldn't%20locate.%20Is%20it%20possible%20to%20use%20PowerShell%20to%20find%20all%20SharePoint%20sites%20associated%20with%20a%20specific%20hub%20site%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJ%20Justin%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-922219%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-922508%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20all%20SharePoint%20sites%20associated%20with%20a%20hub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-922508%22%20slang%3D%22en-US%22%3EYes%2C%20it's%20possible...but%20a%20little%20bit%20tricky%3A%3CBR%20%2F%3E-%20You%20need%20the%20Hub%20Site%20Id%3CBR%20%2F%3E-%20Then%20you%20can%20use%20the%20%24SPOSites%20%3D%20Get-SPOSite%20-Limit%20ALL%20and%20simply%20match%20for%20every%20site%20the%20HubSiteId%20property%20with%20the%20Hub%20Site%20Id%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-926514%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20all%20SharePoint%20sites%20associated%20with%20a%20hub%20site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-926514%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E%26nbsp%3BThanks%20very%20much.%20As%20someone%20reported%20earlier%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-PowerShell%2FBug-The-mysterious-case-of-Get-SPOSite%2Fm-p%2F342684%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-PowerShell%2FBug-The-mysterious-case-of-Get-SPOSite%2Fm-p%2F342684%3C%2FA%3E%26nbsp%3Bthis%20'bug'%20exists%20even%20today.%20I%20can%20get%20the%20desired%20result%20as%20mentioned%20in%20the%20workaround%20section.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJ%20Justin%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I am sure this question might have been answered already, but I couldn't locate. Is it possible to use PowerShell to find all SharePoint sites associated with a specific hub site?

 

J Justin

 

2 Replies
best response confirmed by Justin_J945 (Occasional Contributor)
Solution
Yes, it's possible...but a little bit tricky:
- You need the Hub Site Id
- Then you can use the $SPOSites = Get-SPOSite -Limit ALL and simply match for every site the HubSiteId property with the Hub Site Id

@Juan Carlos González Martín Thanks very much. As someone reported earlier, https://techcommunity.microsoft.com/t5/Windows-PowerShell/Bug-The-mysterious-case-of-Get-SPOSite/m-p... this 'bug' exists even today. I can get the desired result as mentioned in the workaround section.

 

J Justin