Sharepoint - folder permissions and recycle bin

Josef Binder 0 Reputation points
2024-02-05T09:35:57.7866667+00:00

Hello everyone, I would like to ask some questions. We have several libraries on Sharepoint where unique permissions were set at different directory levels. Is there a way to now bulk end unique permissions on all library levels (on all folders and all subfolders) so that everything completely inherits permissions from the main library? The second question: if I change the permissions on the main library, is there a way to make the permissions also apply to the pads that have disabled inheritance from the parent folder? And the last question, is there a way to turn off the fact that deleted files from Sharepoint will be displayed in the Windows Recycle Bin for all users who had the file synchronized via Onedrive to FileExplorer? We have a problem with this, that the user who did not delete the file can then restore it and it makes a mess on Sharepoint. Thank you very much Josef

Microsoft 365 and Office | SharePoint | Development
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 51,846 Reputation points Microsoft External Staff
    2024-02-06T09:19:39.17+00:00

    1.You could use following PNP PowerShell to delete unique permissions for a document library.

    #Set Variables
    $SiteURL = "https://tenant.sharepoint.com/sites/marketing/2018"
    $FolderURL = "/Shared Documents" #Document Library Site Relative URL
     
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive  #-Credentials (Get-Credential)
     
    #Function to reset permissions of all Sub-Folders
    Function Reset-SubFolderPermissions($FolderURL)
    {
        #Get all sub-folders of the Folder - Exclude system folders
        $SubFolders = Get-PnPFolderItem -FolderSiteRelativeUrl $FolderURL -ItemType Folder | Where {$_.Name -ne "Forms" -and $_.Name -ne "Document"}
     
        #Loop through each sub-folder
        ForEach($SubFolder in $SubFolders)
        {
            $SubFolderURL = $FolderUrl+"/"+$SubFolder.Name
            Write-host -ForegroundColor Green "Processing Folder '$($SubFolder.Name)' at $SubFolderURL"
     
            #Get the Folder Object - with HasUniqueAssignments and ParentList properties
            $Folder = Get-PnPFolder -Url $SubFolderURL -Includes ListItemAllFields.HasUniqueRoleAssignments, ListItemAllFields.ParentList, ListItemAllFields.ID
     
            #Get the List Item of the Folder
            $FolderItem = $Folder.ListItemAllFields
     
            #Check if the Folder has unique permissions
            If($FolderItem.HasUniqueRoleAssignments)
            {
                #Reset permission inheritance
                Set-PnPListItemPermission -List $FolderItem.ParentList -Identity $FolderItem.ID -InheritPermissions
                Write-host "`tUnique Permissions are removed from the Folder!"
            }
     
            #Call the function recursively
            Reset-SubFolderPermissions $SubFolderURL
        }
    }
       
    #Call the function
    Reset-SubFolderPermissions $FolderURL
    

    2.If the child folder does not have permission inheritance from its parent folder, there is no option to apply the permission change for the parent folder to the child folder. The only way is you need to manually change permission for the child folder.

    3.It is decided by Windows that deleted files will be move to Windows recycle bin. It cannot be disabled by SharePoint.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.