Advertisement
Guest User

Untitled

a guest
Oct 29th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
  2. $webUrl = "https://sharepoint.DOMAIN.com/";
  3. $web = Get-SPWeb $webUrl;
  4. $oList=$web.Lists["General Documents"];
  5. foreach($folder in $oList.Folders) {
  6.     if($folder.Name -eq "Accounting Department") {
  7.         $query = New-Object Microsoft.SharePoint.SPQuery;
  8.         #$query.Query = "<Where><Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></Where>";
  9.         $query.Folder = $folder.Folder;
  10.         $query.ViewAttributes = "Scope='RecursiveAll'";
  11.         $folderItems = $olist.GetItems($query)
  12.         foreach($item in $folderItems) {
  13.             if($item.HasUniqueRoleAssignments) {
  14.                 Write-Host "Inheritance needs to be reset on" $item.url
  15.                 #$item.ResetRoleInheritance()  
  16.                 #$item.Update()
  17.                 }
  18.             }
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement