I have a list with a multi select (user and group) field. I want to grab the values from there and then pass them to the add permissions method.

I grab the values but they come out like this

12;#Hanks, Tom 13;#Portal Visitors

How can I convert this into something that can be passed into the New-Object Microsoft.SharePoint.SPRoleAssignment method so I can add their name to permissions, whether its a user or group?

If I try ensure user on Hanks, Tom, won't that be an issue incase there are 2 people called Tom Hanks?


1 Answer 1


The value from a multi-user field is actually a user object. You should be able to do the following to ensure the user from login name and add role assignments:

if (!(Add-PSSnapin microsoft.sharepoint.powershell -EA SilentlyContinue)) {
    Add-PSSnapin microsoft.sharepoint.powershell -EA SilentlyContinue
# get web
$web = Get-SPWeb http://myintranet
# get role def
$role = $web.RoleDefinitions["Contribute"]
# get list
$list = $web.Lists["MyList"]
# get item
$item = $list.GetItemById(1)
# get MultiUser field 'PermUsers' value
$item["PermUsers"] | ForEach-Object {
    # ensure user exists OR get group
    if ($_.User) {
        $user = $web.EnsureUser($_.User.UserLogin)
    } else {
        $user = $web.SiteGroups[$_.LookupValue]
    # add assignment for user
    $assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
    # add role for assignment
    # add assignment to list
# update list
# dispose web

Hope this helps!

Updated to work with both Users and SharePoint Groups.

  • Does this work with groups too?
    – omega
    Commented Jul 4, 2018 at 22:58
  • It does now, I've added a check to see if the User property exists, and set user variable to either User or Group accordingly. Commented Jul 6, 2018 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.