SharePoint Powershell command to stop inheriting permission for sharepoint list and give custom permission

$visitorsSPGroupName = “GroupName”
$spSite = New-Object Microsoft.SharePoint.SPSite(“Site Collection Url”)
$web = $site.OpenWeb(“Web Application Name”)
$list = $web.Lists[“List Name”]
$visitorsSPGroup = $web.Groups[$visitorsSPGroupName]
$list.BreakRoleInheritance($true)
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($visitorsSPGroup)
$assignment.RoleDefinitionBindings.Add(($web.RoleDefinitions | Where-Object { $_.Type -eq “Contributor” }))
$list.RoleAssignments.Add($assignment)
$list.Update()
$web.Dispose()
$spSite.Dispose()

Note: this ps should run under farm administrator

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami