SharePoint 2010: Script to Give Reader Permission for a User in a Site Collection with PowerShell

SharePoint 2010: Script to Give Reader Permission for a User in a Site Collection 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!

$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)
}
}


Note: You need to be Site Collection Admin to use this script.
Leave a Comment
  • Please add 5 and 7 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Comments
  • Ed Price - MSFT edited Revision 3. Comment: Title casing, tags

  • Craig Lussier edited Original. Comment: added en-US to tags and title

Page 1 of 1 (2 items)
Wikis - Comment List
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Ed Price - MSFT edited Revision 3. Comment: Title casing, tags

  • Craig Lussier edited Original. Comment: added en-US to tags and title

Page 1 of 1 (2 items)