Add Ad users Info

hi all,
i want to ask how can i use hash table to insert different attributes to user accounts like if a user has email then insert description, employID, Office and some more attributes from a csv file.

my CSV file contains
Email Address, description, employID, Manager,JobTitle


Hi Ali,

What you can do is:

$CSV = Import-csv path to your CSV file

#As long as you have a primary key in your CSV (common identifier)

Foreach($items in $csv){
get-aduser $ | set-aduser -description $items.description -employeeID $items.employID -Manager $items.manager -jobtitle $items.jobtitle

This should update the the users from the CSV

Hi Alex,
thanks so much. i also get a solution from google but i am not able to understand LDAP Filter attribute highlighted in Bold Letters, can you make me understand

Get-ADUser -LDAPFilter (’(SamAccountName={0})’ -f $user.SamAccountName)

I believe LDAP filters only load that one attribute instead of loading all properties per user in your case, making the search faster

It Means SamAccountName={0} means just load the SamAccountName Property.

Get-ADUser -LDAPFilter (’(SamAccountName={0})’ -f $user.SamAccountName)

If it using the format operator to substitue {0} for the value of $user.SamAccountName

For example

$user = [pscustomobject]@{SamAccountName = "User1"}

'(SamAccountName={0})' -f $user.SamAccountName




Get-ADUser -LDAPFilter ('(SamAccountName={0})' -f $user.SamAccountName)


Get-ADUser -LDAPFilter (SamAccountName=User1)

Many Thanks Curtis, Alex and Mark.