对于有多级web获取getlist会报错:Exception calling “GetList” with “1” argument
$SPWeb = Get-SPWeb -Identity http://192.168.0.50:81/oasite/
#注意getlist的写法
$list = $SPWeb.GetList("/oasite/Lists/Facilities and Shared Assets") $item = $list.Items| where{ $_.Name -eq "北京10F第五会议室"} $return = $item.RoleAssignments |where {$_.RoleDefinitionBindings -eq $SPWeb.RoleDefinitions["受限访问"]}; foreach ($i in $return) { Write-Host "Removing: " $i.Member; $item.RoleAssignments.Remove($i.Member); }
断开权限继承
$SPWeb = Get-SPWeb -Identity http://192.168.0.50:81/oasite/ $list = $SPWeb.GetList("/oasite/Lists/Facilities and Shared Assets") $item = $list.Items| where{ $_.Name -eq "北京10F第五会议室"} $item.BreakRoleInheritance(true) $return = $item.RoleAssignments |where {$_.RoleDefinitionBindings -eq $SPWeb.RoleDefinitions["受限访问"]}; foreach ($i in $return) { Write-Host "Removing: " $i.Member; $item.RoleAssignments.Remove($i.Member); }