$sc = New-Object Microsoft.SharePoint.SPSite($webURL)
$web = $sc.OpenWeb()
$list = $web.Lists[$listName]
$web = $sc.OpenWeb()
$list = $web.Lists[$listName]
#Assign read permissions to the site group - faster
$permission = $web.RoleDefinitions["Read"];
$principal = $web.SiteGroups[""]; (if single user, use $web.Users[""]
$assignment = new-object Microsoft.SharePoint.SPRoleAssignment($principal)
$assignment.RoleDefinitionBindings.Add($permission)
$permission = $web.RoleDefinitions["Read"];
$principal = $web.SiteGroups["
$assignment = new-object Microsoft.SharePoint.SPRoleAssignment($principal)
$assignment.RoleDefinitionBindings.Add($permission)
foreach ($item in $list.Items)
{
write-host $item.Title
$itemAssignment = $item.RoleAssignments
$itemAssignment.Add($assignment)
write-host "Permission granted"
}
{
write-host $item.Title
$itemAssignment = $item.RoleAssignments
$itemAssignment.Add($assignment)
write-host "Permission granted"
}
$web.Dispose()
No comments:
Post a Comment