Setting Active Directory Attributes

by Dec 9, 2014

ActiveDirectory Module

To set AD attributes for a user account, PowerShell uses hash tables. That’s a versatile approach that lets you specify any attribute name and associate it with any value.

This simple example would set the attributes “l” and “mail” for the user “testuser”. You can add as many key-value pairs to the hash table as you want, provided the attribute names do exist in your AD schema, and the data type you assign to them is valid:

$infos = @{}
$infos.l = 'Bahamas'
$infos.mail = 'sunny@offshore.com'

Set-ADUser -Identity testuser -Replace $infos 

Twitter This Tip! ReTweet this Tip!