Wednesday, January 14, 2015

How to create sharepoint Group with read only permissions using powershell for entire site?

* Please update URL in script

$site = Get-SPSite -Identity "http://test"
$web =Get-SPWeb -Identity $site.RootWeb
$web =$site.OpenWeb()
$web.SiteGroups.Add(“$web ReadOnly”, $web.Site.Owner, $web.Site.Owner, “Use this group to grant people read permissions to the $web site”)
$visitorsGroup = $web.SiteGroups["$web ReadOnly"]
$visitorsGroup.AllowMembersEditMembership = $true
$visitorsGroupAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($visitorsGroup)
$visitorsRoleDefinition = $web.Site.RootWeb.RoleDefinitions["Read"]

Please follow below URL for .ps1 file

No comments:

Post a Comment

Google+ Followers