function checkFolderPremissions($fld){
if($fld.Item -ne $null -and $fld.Item.HasUniqueRoleAssignments ){
Write-Host "D:$($fld.ServerRelativeUrl)"
showRights($fld)
}
if($fld.Files.Count -gt 0){
foreach($f in $fld.Files){
checkFilePremissions $f
}
}
if($fld.SubFolders.Count -gt 0){
foreach($d in $fld.SubFolders){
checkFolderPremissions $d
}
}
}
function checkFilePremissions($fil){
if($fil.Item -ne $null -and $fil.Item.HasUniqueRoleAssignments ){
Write-Host "F:$($fil.ServerRelativeUrl)"
}
}
function showRights($fld){
$dict = New-Object 'system.collections.generic.dictionary[[string],[system.collections.generic.list[string]]]'
foreach($ra in $fld.Item.RoleAssignments){
foreach($rdb in $ra.RoleDefinitionBindings){
if(-not $dict.ContainsKey($rdb.Name)){
$ll = new-object 'system.collections.generic.list[string]'
$dict.Add($rdb.Name, $ll)
}
$ll = $dict[$rdb.Name]
if(-not $ll.Contains($ra.Member.Name)){
$ll.Add($ra.Member.Name)
}
}
}
$dict
}
$w = Get-SPWeb http://xxxxxx.com/sites/Policies
$lists = @( "KEMH", "MWI")
foreach($list in $lists){
$l = $w.Lists.TryGetList($list)
if($l -eq $null){
throw "List not found: $($list)"
}
$rf = $l.RootFolder
checkFolderPremissions $rf
}
Comments