Author Posts

July 13, 2016 at 4:13 am

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


July 13, 2016 at 7:16 am

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

  • This reply was modified 2 years, 1 month ago by  Alex.

July 13, 2016 at 10:46 am

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)

July 13, 2016 at 10:57 am

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

July 13, 2016 at 11:33 am

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

July 13, 2016 at 6:19 pm

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)

July 16, 2016 at 6:47 am

Many Thanks Curtis, Alex and Mark.