Add Custom Permission Levels using PowerShell
$spSite = Get-SPSite "http://abc/sites/xyz"
$spWeb = $spSite | Get-SPWeb
# we add a new Permission Level
name "MyCustomPermission" to the site, which will allow users to only
add new items (no editing or removing)
# check to see if the permission
your are going to add is already existing.. if null proceed
if($spWeb.RoleDefinitions["MyCustomPermission"] -eq $null)
{
$spRoleDefinition = New-Object Microsoft.SharePoint.SPRoleDefinition
$spRoleDefinition.Name = "MyCustomPermission"
$spRoleDefinition.Description = "Can only
Add items"
$spRoleDefinition.BasePermissions
= "ViewListItems,
AddListItems, Open, ViewPages"
$spWeb.RoleDefinitions.Add($spRoleDefinition)
}
$spWeb.Dispose()
No comments:
Post a Comment