Power Automate : Scrubbing SharePoint Permissions spotlessly Clean !

Power Automate : Scrubbing SharePoint Permissions spotlessly Clean !

If your SharePoint document library permissions have spiraled out of control and links to sensitive files are scattered like confetti at a parade, it’s time to unleash the power of Power Automate with REST API.

We need to “Understand the Challenge”

Unique permissions in SharePoint are like those awkward office plants that seemed like a good idea but now require constant attention. When left unchecked, they multiply and create a tangled mess. Meanwhile, SharePoint sharing links can lead to data exposure if improperly managed.

Power Automate, combined with SharePoint’s REST API can:

  • Identify items or folders with unique permissions.
  • Reset them to inherit permissions from their parent.
  • Delete sharing links to tighten security

Additionally, this approach is particularly useful for large libraries with over 5000 items, where the SharePoint GUI may start acting weird and not allow you to perform these tasks manually. Automating the process ensures consistent results even when the user interface becomes unreliable.
Before diving into automation, make sure you have:

  • Access to Power Automate: Licensed and ready to flow.
  • Permissions in SharePoint: Access to the site and permissions execute REST API calls.
    SOME
  • REST API Basics: your best friend for this mission.
  • Bearer Token from Graph Explorer: To authenticate REST API calls with elevated permissions the quickest and laziest way.

So let’s catch a shiny token !

To execute REST API calls with proper authentication, you’ll need a Bearer Token. Here’s how to obtain one using Microsoft Graph Explorer:

  • Access Microsoft Graph explorer website.
  • Sign In
  • Use your Microsoft account to sign in. Ensure you have the necessary permissions for the SharePoint actions you plan to perform.
  • Run a Sample Query.
  • Retrieve the Access Token.
  • Copy the value, it will look something like eyJ0eXAi….

But remember : Bearer Tokens are temporary and may expire after a certain period. Retrieve a fresh token as needed.!

Now, it is time to Setting Up the Flow:
For our example, let’s go with a manual trigger so you can run the flow on demand.

  • Initialize a new variable to handle our bearer value.
  • Use the Get Files (Properties Only) to fetch items from your library.
  • To reinstate inheritance, call the SharePoint REST API using the”Send an HTTP Request to SharePoint action” and the command :
_api/web/lists/getbytitle('Documents')/items(<itemID>)/ResetRoleInheritance

Tada ! …

Cleaning up large SharePoint document library doesn’t have to be a dreaded chore. With Power Automate and REST API, you can effortlessly restore order, protect sensitive information, and keep your SharePoint environment humming smoothly. No more late-night firefighting, just click Run Flow and let the magic happen!

Spread the love
Viva Engage, We Need to Talk About These Communities

Viva Engage, We Need to Talk About These Communities

Your AI, Your Rules: How to Teach Copilot to Stay in Its SharePoint Lane Pt.3

Your AI, Your Rules: How to Teach Copilot to Stay in Its SharePoint Lane Pt.3

Leave a Reply

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