Get All the Public or Private Team Sites in SharePoint with PnP.PowerShell

When you create a Team Site in SharePoint, you have an option to set the Team Site as:

  • Public – anyone in the organization can access this site, or
  • Private – only members can access this site

Many people don’t know what the effect this setting has – I need to remind myself from time to time.

Private means the site is not discoverable; only people who are assigned specific permissions for the site can find it – even if they happen to guess the URL. Private Team Sites make sense when even knowing the name of the Team Site might be problematic. “Surprise Birthday Party” or “Firing People” come to mind.

Public means the site is discoverable; anyone in the organization can find the site using search or even just guessing the URL. More important, when you create a site as Public, the Everyone except external users pseudogroup is added to the Members for the site. This means every licensed user can add and edit content – unless you change the permission settings.

If any of the above is a surprise to you, well I’m not surprised by that. I don’t think the wording on the Create site dialog is all that clear, and unless I’m missing something, I can’t find a Microsoft article which explains it in the amount of detail I give above.

If you’d like to know what the setting is for any particular site, here’s how you’ll know. As of this writing (it’s moved around a bit in the past and can vary based on your header settings for the site), you can tell if a site you’re visiting is Public or Private by looking in the upper right on the home page:

That’s well and good if you have a site or two to check. But what if you’d like to know how all your sites are set up? Time to turn to trusty PnP.PowerShell. I needed to do this today and it was really hard to figure out where the setting was available. Turns out, it’s not a setting on the site itself, but on the underlying Microsoft 365 Group.

Once I knew that, easy-peasy.

This single line of PnP.PowerShell will retrieve all the Microsoft 365 Groups where the Visibility property is set to Private. If you want the Public sites, well I’ll leave that to you, dear reader.

Get-PnPMicrosoft365Group -IncludeSiteUrl | Where-Object { $_.Visibility -eq "Private"}

Of course, you’ll need the appropriate permissions and you’ll need to have connected to the SharePoint Admin site with Connect-PnPOnline first.


If you’d rather not use PowerShell (and Todd will be offended of you don’t!), you can also see this setting in the Exchange admin center (microsoft.com) in the Groups listing. That listing can be exported to Excel if you’d like to do more slicing and dicing.

References

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.