mardi 3 mars 2015

Remove item level permission for specific user using powershell



I want to remove the permission for each item and then want to add my unique permission I have tried the code for giving permission. But firstly, i want to remove it and then add new permission. My code is as below:



$clientlist.Items | ForEach-Object{

$contentTypeName=$_.ContentType.Name
if($contentTypeName -eq 'Proposal')
{
$clientlist.BreakRoleInheritance($True)
$userNew = $webNew.EnsureUser($user)
$roleDefinition = $webNew.RoleDefinitions[$PermissionLevel]
$roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($userNew)
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
$clientlist.RoleAssignments.Add($roleAssignment)
$clientlist.Update()
Write-Host "Successfully added $PermissionLevel permission to $UserNew in $clientlist list. " -foregroundcolor Green
}
}


Thanks.








0 commentaires:

Enregistrer un commentaire