Change External Sharing Settings Across a Hub Site with PowerShell

Change External Sharing Settings Across a Hub Site with PowerShell

One of the big Information Architecture changes with modern SharePoint is the flat architecture, which means that now, instead of your Intranet being one Site Collection with multiple subsites, it will now be multiple Site Collections. I’ve seen multiple example architectures where an Intranet can easily become over 15 Site Collections! That means, each Site Collection has its own settings, including external access! While a new SharePoint Admin Center is shipping, you cannot bulk-change External Sharing settings.

So I have built a quick PowerShell script that you can simply provide the URL of a Hub Site and the level of external sharing you want to enable, and it will do the magic for you! The script seen below requires two parameters, and it has some validations in to make sure you supply the right type of values.

  1. HubSiteUrl : The URL of a Hubsite
  2. ExternalSharing : one of the following options:
    1. Disabled – don’t allow sharing outside your organization
    2. ExistingExternalUserSharingOnly – Allow sharing only with the external users that already exist in your organization’s directory
    3. ExternalUserSharingOnly – allow external users who accept sharing invitations and sign in as authenticated users
    4. ExternalUserAndGuestSharing – allow sharing with all external users, and by using anonymous access links.

If you examine the script, you will realize that I run the Get-SPOSite twice , that is because when you run Get-SPOSite without specifying a URL , it doesn’t return the HubSiteId , so that’s why we have to do it!

Download the following script and save it as HubExternal.ps1.

Here is an example on how to run it:

And this is what it should look like when running it!

External Sharing Settings Across a Hub Site

I hope this helps! You can of course modify this script to take the same logic, and do a bunch of different changes on all the Site Collections in a certain Hub Site!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (4)

Please rate this


No comments yet.

Leave a Reply