1

In SharePoint 2010, I have a site collection with several subsites and hundreds of document libraries in sub sites. All these libraries have unique permissions. I have created 4 new SharePoint Groups in parent site collection. I want these security groups to be added into unique permissions of libraries of subsites. Is it possible through powershell or any other OOB technique?

1

You can try the following PowerShell script to add groups to list/library permissions. Iterate lists and libraries in the site and execute the function.

function Add-SPPermissionToListGroup
{
    param ($Url, $ListName, $GroupName, $PermissionLevel)
    $web = Get-SPWeb -Identity $Url
    $list = $web.Lists.TryGetList($ListName)
    if ($list -ne $null)
    {
        # Ensure that the permissions are not being inherited.
        if ($list.HasUniqueRoleAssignments -eq $True)
        {
            if ($web.SiteGroups[$GroupName] -ne $null)
            {
                $group = $web.SiteGroups[$GroupName]
                $roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
                $roleDefinition = $web.RoleDefinitions[$PermissionLevel];
                $roleAssignment.RoleDefinitionBindings.Add($roleDefinition);
                $list.RoleAssignments.Add($roleAssignment)
                $list.Update();
                Write-Host "Successfully added $PermissionLevel permission to $GroupName group in $ListName list. " -foregroundcolor Green
            }
            else
            {
                Write-Host "Group $GroupName does not exist." -foregroundcolor Red
            }
        }      

    }
    $web.Dispose()
    }

Refer to: Using powershell to work with SharePoint groups

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.