How To Stop External Site Sharing In SharePoint Using Power Automate

Introduction

In this article, I will show you how to prevent external sharing of a SharePoint site using power automate. We can archive this using rest API.

We don't need to go each and every site setting to change them; just create power automate for the same. 

Steps

Step 1: Create Power Automate Flow.

Step 2:  Add Send an HTTP request to SharePoint Actions to your flow.

stop external sharing of the site using power automate

Step 3: Add your SharePoint admin URL to the Site Address.

Example:  https://example-admin.sharepoint.com

stop external sharing of the site using power automate

Step 4: Select POST inside the Method box.

stop external sharing of the site using power automate

Step 5: Pass the below endpoint to Uri box.

Example:  _api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites(`Pass your site ID`)

Note: You can get your site id using the phrase below.

https://<tenant>.sharepoint.com/sites/<site-url>/_api/site/id

stop external sharing of the site using power automate

Step 6: Pass header as written below.

{
  "accept  ": "application/json;odata=verbose",
  "content-type": " application/json;odata=verbose",
  "X-HTTP-Method": "MERGE"
}

stop external sharing of the site using power automate

Step 7: Pass body as written below.

{
"__metadata": {
"type": "Microsoft.Online.SharePoint.TenantAdministration.SiteProperties"
},
"SharingCapability":0
}

stop external sharing of the site using power automate

Output

stop external sharing of the site using power automate

Conclusion

This is how we can easily prevent external sharing of a site using power automate.