Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

Get list of all documents with unique permissions (Power Automate)

Posted on April 12, 2023April 12, 2023 by Tom

“I’d like to restore original permissions on all documents in a SharePoint library, how can I list files with unique permissions in a Power Automate flow?”


When restoring library permissions, it’ll remove all unique permissions on the library itself and use the site permissions instead. But that doesn’t mean it’ll restore permissions also on all the files in that library. If the permission inheritance is broken, the library settings doesn’t have any effect on such files.

Yet often you want to restore all permissions, on all the folders and all the files. How do you do that? How do you list all the files/folders with unique permissions to inherit them again?

Get the files with an HTTP request

The good news is that each file in the document library has a property called ‘HasUniqueRoleAssignments’ that’ll give you such information. The bad news is that this property is not accessible using the ‘Get files (properties only)’ action. As such, you’ll need an HTTP request to SharePoint where you’ll ask for this property specifically with the $select parameter. Since you’ll need also the id of the item to restore the permissions, take also the id.

Method: GET

Uri: _api/web/lists/getByTitle('<libraryName>')/items?$select=HasUniqueRoleAssignments,id

Notes: <…> are placeholders, replace them including the < and >. If you’d like also the file name/path/type you can add the corresponding properties to the $select.

Power Automate documents unique permissions

This action will return all files in the library, not only the ones with unique permissions…

You’ll have to filter the results using the ‘Filter array’ action to keep only files whose ‘HasUniqueRoleAssignments’ equals true.

Navigate in the HTTP request output to get the array with the results…

body('Send_an_HTTP_request_to_SharePoint')?['d']?['results']

…and keep only the files whose HasUniqueRoleAssignments is true.

item()?['HasUniqueRoleAssignments']

The result will be only files with unique permissions. As you have their id, you can restore them to the original permissions – file by file, folder by folder.

Power Automate documents unique permissions

Summary

To restore permissions on all files and folders in a SharePoint library, you must know ids of these files. And even though Power Automate doesn’t have a dedicated action that would list those documents with unique permissions, there’s still an HTTP request to save the day. List all the files including the ‘HasUniqueRoleAssignments’ property, filter only the ones where it’s true, and restore the permissions with another HTTP request.


πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

10 thoughts on “Get list of all documents with unique permissions (Power Automate)”

  1. Priya Sivaji says:
    May 23, 2023 at 2:26 pm

    This is great!!! I am just stuck in the last part- Apply to each – Send an HTTP request to SharePoint 2 – the item() expansion could you please provide a screen capture of how you added the ID of the HasUniqueRoleAssignment items

    Reply
    1. Tom says:
      August 12, 2023 at 10:22 pm

      Hello Priya,
      it’s in the note of the action – expression item()?[‘id’]

      Reply
  2. Jim Zoetewey says:
    June 23, 2023 at 6:46 pm

    I’m trying to use this with our Sharepoint site, but I’m getting the error, “A potentially dangerous Request.Path value was detected from the client.”

    I’m guessing that the issue is that Documents has 126,000 files. I’m not sure how to get around this.

    Reply
    1. Tom says:
      August 12, 2023 at 11:08 pm

      Hello Jim,
      me neither, I’ve never seen this error.

      Reply
  3. Emma says:
    July 21, 2023 at 12:41 am

    I have the same problem as Priya. How do you get the id from the filtered array?

    Reply
  4. Emma says:
    July 21, 2023 at 12:45 am

    Never mind. I found it. The expression: item()[‘ID’]

    Reply
  5. Dev says:
    August 3, 2023 at 6:59 am

    Hello, this has been helpful but I’m also wondering how would I be able to retrieve what permission level was given to that certain item?

    Reply
    1. Tom says:
      September 7, 2023 at 12:05 pm

      Hello Dev,
      I guess it’s possible, I’ll add it to my list of potential future topics

      Reply
  6. Steve Morley says:
    March 26, 2024 at 7:49 pm

    Hi Tom,
    What if I only want to get a list of the files with unique permissions and email the owner?

    Reply
    1. Tom says:
      April 17, 2024 at 10:19 pm

      Hello Steve,
      the ‘Filter array’ will give you Id’s of the files – you can take it, get the properties for each of the files including e.g. the author (owner?), and send him an email.

      Reply

Leave a Reply Cancel reply

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

πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Working on an Approval process?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy a fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes