0

I'm updating custom fields in a document library and I have to set a value for the person that's responsible for the file. On the frontend I put the AD account name in the field but it is stored as a numeric user id. How can I get this id using powershell if I have the AD account name?

4
$web = Get-SPWeb URLTOWEB    
$user = $web.EnsureUser("USERLOGINNAME")
$id = $user.ID

Now $id will contain the ID of the user

1

This is a custom field. We don't know it's behavior. Probably, your field stores SPUser.Id property value. In this case method SPWeb.EnsureUser helps you get SPUser object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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