SharePoint 2010: Give Reader Permission for a User with PowerShell

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!


$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 6 and 8 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Ed Price - MSFT edited Revision 2. Comment: Title, tags

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

Page 1 of 1 (2 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Craig Lussier edited Original. Comment: added en-US to tags and title

  • Whilst this might not be the right way to add individual users, I can see a change to this being quite useful for adding users in bulk.

    Have you considered adding this article to the Galleries?

  • Ed Price - MSFT edited Revision 2. Comment: Title, tags

Page 1 of 1 (3 items)