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.
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.
Setting | MembersCanShare | AllowMembersEditMembership |
---|---|---|
Site owners and members can share files, folders, and the site. People with Edit permissions can share files and folders | True | True |
Site owners and members, and people with Edit permissions can share files and folders, but only site owners can share the site | True | False |
Only site owner can share files, folders, and the site. | False | False |
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.
1. Add a Manually trigger a flow action.
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.
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.
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.
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.
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.
Happy testing!