PowerShell Set-ADUser

SEHC
SEHC used Ask the Experts™
on
Hi

I am trying to set up the command to Set-ADUser via the users employeeID and to add a comment in to the extensionAttribute.  I am hoping someone can help I looked at the MS site but I think I am missing something here.

Set-ADUser -EmployeeID "12345" -extensionAttribute12 "1235"
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Raheman M. AbdulMessaging and Directory Services

Commented:
Try this:
Set-Mailbox -Identity "12345" -ExtensionCustomAttribute12 @{Add="12345"}

you need to use Set-QADUser instead.
Raheman M. AbdulMessaging and Directory Services

Commented:
Try this:
set-aduser -identity "12345" -add @{extensionAttribute12='1235' }
SEHCAdmin

Author

Commented:
Set-Mailbox -Identity "12345" -ExtensionCustomAttribute12 @{Add="12345"}

the Identity in the command line is username not employeeID as I want to use that as the lookup for the user.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
You first need to find the AD user with Get-ADUser, and then modify the AD object using some complex syntax:
Get-ADUser -Filter {EmployeeID -eq '12345'} |
  Set-ADUser -Clear extensionAttribute12 -Add @{extensionAttribute12='1235'}

Open in new window

You can omit the -Clear if you are certain the attribute is empty.
SEHCAdmin

Author

Commented:
that did not work??
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
First try the Get-ADUser with filter, without the pipeline. That shows whether there is an object found:
Get-ADUser -Filter {EmployeeID -eq '12345'}

Open in new window

Does that return an user?
SEHCAdmin

Author

Commented:
Get-ADUser -Filter {EmployeeID -eq '12345'}  works after I add the Pipe it does nothing
Justin YeungSenior Systems Engineer
Commented:
@ Qlemo, I don't think you have to clear and add the attribute. you can use -replace instead
Get-ADUser -Filter {EmployeeID -eq '12345'} |
  Set-ADUser -Replace @{extensionAttribute12='1235'} 

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial