I have tried using the below to add specific user to items but it keep getting error. For now I'm just trying to add permission to specific item but I would be changing the code to look at a column of a people picker type with multiple users.
I would appreciate if someone can tell me what I'm doing wrong
Exception calling "Add" with "1" argument(s): "" At +
$CMRSItems.RoleAssignments.Add($assignment)
$web.AllowUnsafeUpdates = $true
$user = $web.EnsureUser("domain\username")
$role = $web.RoleDefinitions["Read"]
$CMRSItems = $list.Items | where {$_['ID'] -eq 2}
$CMRSItems | ForEach-Object {
Write-Host "ItemID: " $_['ID']
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$assignment.RoleDefinitionBindings.Add($role)
#$web.RoleAssignments.Add($assignment);
$CMRSItems.RoleAssignments.Add($assignment)
$CMRSItems.Update()
$web.Dispose()
}