Set Site Sharing settings

Within SharePoint Online it is possible to update sharing settings per site. In this article I will show you how to update the site sharing settings for a single site collection via a Power Automate flow.

Inspiration

This question from Ntriplet:

Is it possible to change a SPO Site Sharing settings with Power Automate?

Power Users Community thread: SPO Site Sharing Settings.

sitesharingsettings

Two properties One setting

In the interface you have three options for the Site sharing setting. From a programming point of view I was expecting a single enumeration type property with three values. However, I was wrong 😉

Two properties play a role in this single setting. The MembersCanShare boolean property and the AllowMembersEditMembership boolean property of the associated Members group. (nested within AssociatedMemberGroup property).

In the table below I have outlined which combination of boolean values are used for which setting.

SettingMembersCanShareAllowMembersEditMembership
Site owners and members can share files, folders, and the site. People with Edit permissions can share files and foldersTrueTrue
Site owners and members, and people with Edit permissions can share files and folders, but only site owners can share the siteTrueFalse
Only site owner can share files, folders, and the site.FalseFalse

Flow Setup

For this sample I am using some input variables and an array variable for mapping the boolean properties to the single site sharing setting.

setsitesharingsetting

1. Add a Manually trigger a flow action.

siteaddress_sharingchoice_trigger

a. Add a text input variable, in this example SiteAddress
b. Add a number input variable, in this example SharingChoice

2. Add a Initialize variable action.

sitesharingarray

a. Provide a Name, in this example SiteSharingArray
b. Select a Type, Array
c. Provide a Value, in this case the json from the code snippet below.

3. Add a Filter Array action.

filterarray_sitesharing

a. Use the SiteSharingArray in the From
b. Switch the Where to advanced mode
c. Provide a Value, in this case the json from the code snippet below.

4. Add a Send an HTTP request to SharePoint action.

memberscanshare_http

a. Use the SiteAddress input variable from the trigger action as a custom value.
b. Use the POST method
c. Use the URI from the code snippet below

d. Use the Headers from the code snippet below

e. Use the Body from the code snippet below

5. Add a second Send an HTTP request to SharePoint action.

AllowMembersEditMembership_http

a. Use the SiteAddress input variable from the trigger action as a custom value.
b. Use the POST method
c. Use the URI from the code snippet below

d. Use the Headers from the code snippet below

e. Use the Body from the code snippet below

That should be it for the setup. Just test it and enter some input when running the flow like in the screenshot below.

testrunflow

Happy testing!

You may also like...

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.