다음을 통해 공유


SharePoint 2010: Give Reader Permission for a User with PowerShell

This script will ensure reader permissions to specified user across site collection.

Keep in mind: This is not the right way to deal with permissions issues!

Note: You need to be Site Collection Admin to use this script.

$site = Get-SPSite -Identity "http://mysite/"
$user = Get-SPUser -Identity "mydomain\myuser"  -Web $site.RootWeb
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$role = $site.RootWeb.RoleDefinitions[[Microsoft.SharePoint.SPRoleType]::Reader]
$assignment.RoleDefinitionBindings.Add($role);
 
foreach ($web in $site.AllWebs) {
if ($web.HasUniquePerm) {
$web.RoleAssignments.Add($assignment)
} 
}