Friday, 4 February 2011

Configuring permissions on a list with powershell

Little of code:

$URL = "http://foo.bar" 
$web = Get-SPWeb -identity $URL/Workers/AbsenceReport
$list = $web.Lists["Absence report"]
$group = $web.SiteGroups["Visitors of the web"]
$assignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
$assignment.RoleDefinitionBindings.Add($web.RoleDefinitions["Contribute"])
$list.BreakRoleInheritance($true)
$list.RoleAssignments.Add($assignment)
$list.Update()


one thing: role definitions are localized, so in polish it isn't "Contribute" but "Współtworzenie"

No comments:

Post a Comment