Friday, August 10, 2012

Modifying Custom AD Attributes w/Powershell

Recently I needed to create a custom user attribute within our Active Directory environment.  Rather than manually edit each user with the new value, I thought of using Powershell to automate the process.  I began testing the process using set-aduser.  Generally you'd find the associated property and add the value:

set-aduser username -EmailAddress username@domain.com

The custom attribute I created was EmployeeDOB so I ran the same command but the property was not recognized.  After some research and help from the Technet forums, I was introduced to the following options:

set-aduser username -Add @{EmployeeDOB='5-1-1978'}

set-aduser username -Replace @{EmployeeDOB='4-1-1980'}

set-aduser username -Remove @{EmployeeDOB='4-1-1980'}

With this new knowledge, I can now hopefully save some time by not having to manually edit these values within ADUC!!

6 comments:

  1. Legen-wait for it-dary.
    Thanks so much, was struggling with this for ages

    ReplyDelete
  2. Thanks! This helped me when scripting a custom AD attribute of remoteOfficeLocation. Perfect.

    ReplyDelete
  3. Thanks a lot, this helped me a lot

    ReplyDelete
  4. Our client uses these LDAP fields a lot for integration with other tools - big help now I can update these en-masse, couldn't find the command anywhere!

    ReplyDelete
  5. I am glad this has been helpful to people!

    ReplyDelete