Is it possible to loop through every site via powershell and set the default document library to all owned sites (including Team sites) to be read-only for everyone but the owners? I've seen and tried a lot of code but I cannot get it to work.

I only want the Team Owner to be able to create documents.

Thank you.

  • May I ask why do you want to achieve that ? Because the main purpose a site owner is to have full-control. Maybe you should consider another approach.
    – a1mery
    Mar 5, 2020 at 7:28
  • Fixed the question, I meant to say everyone but owners to read-only.
    – g33kphr33k
    Mar 6, 2020 at 19:44

1 Answer 1


You can use Set-PnPListPermission to remove and add users/groups permissions.

If you want to change all libraries of all sites, you need to loop them, then run Set-PnPListPermission to change permissions for each library.

Two blogs for your reference:
SharePoint Online: Remove User or Group from List Permissions using PowerShell
SharePoint Online: Grant Permission to List or Library using PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.