Adding Custom Attributes to AD Objects

by Jul 16, 2015

If you’d like to add custom attributes to an AD object, simply use a hash table, and add the desired attribute names and their values. Then use Set-ADUser (available in the ActiveDirectory module shipping with the free RSAT tools from Microsoft).

This example would add two extensionAttributes to the current user account (always make sure you are NOT damaging attributes that are vital for your infrastructure! Use a test environment to play):

#requires -Version 1 -Modules ActiveDirectory
# create an empty hash table
$custom = @{}

# add the attribute names and values
$custom.ExtensionAttribute3 = 12
$custom.ExtensionAttribute4 = 'Hello'

# assign the attributes to your current user object
$user = $env:USERNAME
Set-ADUser -Identity $user -Add $custom

It is important to pick the correct parameter. Use –Add to add a new value to the attribute. Use –Remove to remove an existing value. And use –Replace to replace the attribute with a new value.

Twitter This Tip! ReTweet this Tip!