powershell 这将遍历站点中的所有子站点,并且添加组可设置组的权限。打破或重置的好例子
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 这将遍历站点中的所有子站点,并且添加组可设置组的权限。打破或重置的好例子相关的知识,希望对你有一定的参考价值。
Add-PsSnapin Microsoft.SharePoint.PowerShell
function setPermissions($NewGroup,$PermissionLevel,$web)
{
#Assign Permissions to the Group
$group = $web.SiteGroups[$NewGroup]
$GroupAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
#Get Full Control Role (Permission Level)
$GroupRoleDefinition = $web.Site.RootWeb.RoleDefinitions[$PermissionLevel]
#Bind Full Control
$GroupAssignment.RoleDefinitionBindings.Add($GroupRoleDefinition)
#Grant Full control to the Web
$web.RoleAssignments.Add($GroupAssignment)
}
$topSite = Get-SPWeb http://scushp01/Branches
foreach($s in $topSite.Webs)
{
##$s.Update()
##$s.ResetRoleInheritance()
##$s.BreakRoleInheritance($False)
##$s.Update()
$s.Title
$NewMembers = $s.Title + " Members"
$NewVisitors = $s.Title + " Visitors"
$NewEditors = $s.Title + " Editors"
$NewDesigners = $s.Title + " Designers"
$NewOwners = "TheSound Owners"
setPermissions $NewMembers "Contribute" $s
setPermissions $NewVisitors "Read" $s
setPermissions $NewEditors "Edit" $s
setPermissions $NewDesigners "Design" $s
setPermissions $NewOwners "Full Control" $s
}
以上是关于powershell 这将遍历站点中的所有子站点,并且添加组可设置组的权限。打破或重置的好例子的主要内容,如果未能解决你的问题,请参考以下文章