script-samples icon indicating copy to clipboard operation
script-samples copied to clipboard

PnP Script reset-files-permission-unique-to-inherited throws list exceeds threshold for large libraries

Open reshmee011 opened this issue 3 years ago • 0 comments

PnP PowerShell script reset-files-permission-unique-to-inherited throws list exceeds threshold for large libraries. I have an alternate version to work with large libraries ` try { Get-PnPListItem -List $ListName -PageSize 2000 | Where {$.FieldValues.FileRef -like "$FolderServerRelativePath*" -and $.FileSystemObjectType -eq "File" } | ForEach-Object { $hasUniqueRole = Get-PnPProperty -ClientObject $_ -Property HasUniqueRoleAssignments if($hasUniqueRole -eq $true){ Write-host $.FieldValues.FileRef Write-host "Reset Permisison starting for file with id $($.Id)" -ForegroundColor DarkGreen $.ResetRoleInheritance() $.update() $Context.ExecuteQuery() } } } catch { write-host "Error: $($_.Exception.Message)" -foregroundcolor Red }

` @pkbullock , would you recommend refactoring the current code to work with large libraries or shall I add a new scenerio?

reshmee011 avatar Oct 15 '22 13:10 reshmee011