Forum Discussion

Nico Martens's avatar
Nico Martens
Brass Contributor
Feb 15, 2019

Bug - The mysterious case of Get-SPOSite

Background

Sometimes you run into weird issues when you are doing the most common things. In this case, my colleague Marc Molenaar was cleaning up our 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 our 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 we 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.

 

The problem

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

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

 

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://sharepointrelated.sharepoint.com/sites/intranet-EN | Select URL, IsHubSite Get-SPOSite

 

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://sharepointrelated.sharepoint.com/sites/intranet-EN | Select URL, IsHubSiteGet-SPOSite You can also use the Get-SPOHubSite cmdlet to get all Hub Sites in your tenant. Here is the result: Get-SPOHubSite

Hopefully this helps you find your Hub Sites succesfully!

  • Have you tried the -Detailed switch? There are multiple properties that return "default" values when you run Get-SPOSite, and only show the real value with the -Detailed switch.

    • Nico Martens's avatar
      Nico Martens
      Brass Contributor
      Hi Vasil,

      I tried this just now, unfortunately this doesn't help :(

Resources