none
How to delete unique permissions on all the documents in the Library using Powershell RRS feed

  • Question

  • Hi Guys,

    Do you have any PS script delete unique permissions on all the documents in the Library using SPO Powershell . Please see the snapshot below.

    I need to delete unique permissions on all the documents and keep library in Read only mode. 


    Srini

    Monday, September 23, 2019 10:03 PM

Answers

  • Hi, Srini,

    Have you tried the script? Is there any update about your task? 

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Neel_k Tuesday, October 1, 2019 3:01 AM
    Friday, September 27, 2019 8:35 AM
  • Hi Srini,

    Why is the heading wrong?

    Remove unique permissions  == restore inherited permissions

    What are you trying to achieve? Do you want to delete the entire items?

    • Marked as answer by Neel_k Tuesday, October 1, 2019 3:00 AM
    Sunday, September 29, 2019 11:16 PM

All replies

  • Hi,

    This may help

    https://www.sharepointdiary.com/2016/01/sharepoint-online-delete-unique-permissions-using-powershell.html

    https://social.technet.microsoft.com/wiki/contents/articles/29718.sharepoint-online-powershell-to-delete-unique-permissions-in-all-list-items.aspx-----------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Monday, September 23, 2019 10:15 PM
  • Hi, Srini,

    Please use the script below, it will delete unique permissions on all documents in a SharePoint Online library.

    #Config Variables
    $SiteURL = "your site URL"
    $ListName ="your library name"
     
    #Connect PNP Online
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
     
    #Get the Context
    $Context = Get-PnPContext
      
    #Get the list items
    $items = Get-PnPListItem -List $ListName
    foreach ($item in $items)
    {
    #Remove unique permissions
    $item.ResetRoleInheritance()
    $item.update()
    $Context.ExecuteQuery()
    }

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Proposed as answer by Michael Han6 Thursday, September 26, 2019 6:01 AM
    Tuesday, September 24, 2019 2:48 AM
  • Thanks Jerry. But the script is failing if the list threshold is greater than 5000 below is the error message 

    can you advise ?



    Srini

    Tuesday, September 24, 2019 4:23 AM
  • Hi, Srini,

    Try this script. Remember to change the data in the last line to yours.

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, September 24, 2019 6:11 AM
  • Hi, Srini,

    Have you tried the script? Is there any update about your task? 

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Neel_k Tuesday, October 1, 2019 3:01 AM
    Friday, September 27, 2019 8:35 AM
  • Yes i tried it was restoring unique permissions and it is not deleting. The heading of the blog is wrong

    "Powershell script to restore inherited permissions for all items in a SharePoint Online list."


    Srini

    Sunday, September 29, 2019 12:26 AM
  • Hi Srini,

    Why is the heading wrong?

    Remove unique permissions  == restore inherited permissions

    What are you trying to achieve? Do you want to delete the entire items?

    • Marked as answer by Neel_k Tuesday, October 1, 2019 3:00 AM
    Sunday, September 29, 2019 11:16 PM
  • Hi Arleta,

    ooops I'm sorry this is my mistake :) pasted wrong line here.

    Your script works perfect thank you so much.


    Srini

    Tuesday, October 1, 2019 3:00 AM
  • Thanks Jerry yes it worked.

    Srini

    Tuesday, October 1, 2019 3:01 AM