powershell 此功能打破网站中的角色继承,然后将组添加到每个组的网站设置权限。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 此功能打破网站中的角色继承,然后将组添加到每个组的网站设置权限。相关的知识,希望对你有一定的参考价值。

function setPermissions($NewGroup,$PermissionLevel,$web)
{
    Write-Host "Setting " $PermissionLevel " for " $NewGroup  " in "  $web.Name -ForegroundColor DarkRed -BackgroundColor White
    #Assign Permissions to the Group
    $group = $web.SiteGroups[$NewGroup]
    $GroupAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)

    #Get Full Control Role (Permission Level)
    $GroupRoleDefinition = $topSite.Site.RootWeb.RoleDefinitions[$PermissionLevel]
     
        #Bind Full Control
    $GroupAssignment.RoleDefinitionBindings.Add($GroupRoleDefinition)
 
    #Grant Full control to the Web
    $topSite.RoleAssignments.Add($GroupAssignment)

}
$topSite.Update()
$topSite = Get-SPWeb http://scushp01/Management/BM
$topSite.BreakRoleInheritance($false)
$topSite.Update()

$NewMembers = "Management Board Meetings Members"
$NewVisitors = "Executive Management Visitors"
$NewEditors = "Executive Management Editors"
$NewDesigners = "Executive Management Designers"
$NewOwners = "TheSound Owners"

setPermissions $NewMembers "Contribute" $topSite
setPermissions $NewVisitors "Read" $topSite 
setPermissions $NewEditors "Edit" $topSite 
setPermissions $NewDesigners "Design" $topSite
setPermissions $NewOwners "Full Control" $topSite
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 = $topSite.Site.RootWeb.RoleDefinitions[$PermissionLevel]
     
        #Bind Full Control
    $GroupAssignment.RoleDefinitionBindings.Add($GroupRoleDefinition)
 
    #Grant Full control to the Web
    $topSite.RoleAssignments.Add($GroupAssignment)

}

$topSite = Get-SPWeb http://scushp01/Branches/Auburn
$topSite.BreakRoleInheritance($false)

$NewMembers = "Auburn Members"
$NewVisitors = "Auburn Visitors"
$NewEditors = "Auburn Editors"
$NewDesigners = "Auburn Designers"
$NewDesigners = "TheSound Owners"
setPermissions $NewMembers "Contribute" $topSite
setPermissions $NewVisitors "Read" $topSite 
setPermissions $NewEditors "Edit" $topSite 
setPermissions $NewDesigners "Design" $topSite

以上是关于powershell 此功能打破网站中的角色继承,然后将组添加到每个组的网站设置权限。的主要内容,如果未能解决你的问题,请参考以下文章

powershell 此SharePoint Powershell脚本会检查网站集和Web应用程序中的所有网站,以查找特定的Web模板

powershell 这将遍历站点中的所有子站点,并且添加组可设置组的权限。打破或重置的好例子

Powershell:陷阱继续打破整个循环

powershell 打破例外

powershell 打破天蓝色存储blob上的leas

powershell 此递归PowerShell脚本从SharePoint中删除网站及其所有子网站。这消除了无法进行del的问题