Get-SPOSite Issue and Work Around

We all know that Get-SpoSite cmdlet contains more than one parameter set and you may only use parameters from one parameter set and you may not combine parameters from different parameter sets. Moreover, it retrieves and returns properties of all site collections that match the given criteria.

But sometimes you run into weird issues when you are doing the most common things. In this case, one of my friend was cleaning up his demo Office 365 tenant. To make an overview of all site collections, he ran the following cmdlet:

	Get-SPOSite -Limit All | Export-CSV "C:\temp\sites.csv"

​This would make a list of all site collections that are available in Office 365 tenant and export it to a CSV file. When going through it, he noticed that none of the site collections were flagged as a hubsite. This couldn’t possibly be true as he created many hub sites for testing purposes.

I decided to check this in my own tenant to see if it was a local problem. So let’s see what happens.

Issue

​Running the following PowerShell returns all site collections that contain the word intranet.

Get-SPOSite -Limit All | ?{$_.URL -like "*intranet*"} | select URL, IsHubSite

So it looks like we do not have any hub sites. However, when I check the exact same thing for 1 of the site collections (which I know for sure is a Hub Site) by running:

Get-SPOSite https://abcd.sharepoint.com/sites/intranet-EN | Select URL, IsHubSite

Workaround

The current workaround is to get all site collections, and then use a foreach loop to go through them again and get the property. In my case, I would run:

Get-SPOSite https://abcd.sharepoint.com/sites/intranet-EN | Select URL, IsHubSite

You can also use the Get-SPOHubSite cmdlet to get all Hub Sites in your tenant. Here is the result:

​Hopefully this helps you find your Hub Sites successfully!

Leave a Reply