# Add Ad users Info

**URL:** <https://forums.powershell.org/t/add-ad-users-info/6801>\
**Category:** PowerShell Help\
**Created:** [July 12, 2016, 10:43pm UTC](https://forums.powershell.org/t/add-ad-users-info/6801 "2016-07-12T22:43:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 12, 2016, 10:43pm UTC](https://forums.powershell.org/t/add-ad-users-info/6801/1 "2016-07-12T22:43:34Z")

</div>

hi all,  
i want to ask how can i use hash table to insert different attributes to user accounts like if a user has [this@test.com](mailto:this@test.com) email then insert description, employID, Office and some more attributes from a csv file.

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

thanks

---

<div class="post-metadata">

**Author:** ![alex-innes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/alex-innes/32/129_2.png) [@alex-innes](https://forums.powershell.org/u/alex-innes)\
**Post date:** [July 13, 2016, 1:46am UTC](https://forums.powershell.org/t/add-ad-users-info/6801/2 "2016-07-13T01:46:21Z")

</div>

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 $items.email | set-aduser -description $items.description -employeeID $items.employID -Manager $items.manager -jobtitle $items.jobtitle
}
```

This should update the the users from the CSV

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 13, 2016, 5:16am UTC](https://forums.powershell.org/t/add-ad-users-info/6801/3 "2016-07-13T05:16:12Z")

</div>

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**)

---

<div class="post-metadata">

**Author:** ![mark-prior](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@mark-prior](https://forums.powershell.org/u/mark-prior)\
**Post date:** [July 13, 2016, 5:27am UTC](https://forums.powershell.org/t/add-ad-users-info/6801/4 "2016-07-13T05:27:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 13, 2016, 6:03am UTC](https://forums.powershell.org/t/add-ad-users-info/6801/5 "2016-07-13T06:03:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![curtis-smith](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/curtis-smith/32/121_2.png) [@curtis-smith](https://forums.powershell.org/u/curtis-smith)\
**Post date:** [July 13, 2016, 12:49pm UTC](https://forums.powershell.org/t/add-ad-users-info/6801/6 "2016-07-13T12:49:31Z")

</div>

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
```

**Results:**

```
(SamAccountName=User1)
```

so

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

becomes

```
Get-ADUser -LDAPFilter (SamAccountName=User1)
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [July 16, 2016, 1:17am UTC](https://forums.powershell.org/t/add-ad-users-info/6801/7 "2016-07-16T01:17:31Z")

</div>

Many Thanks Curtis, Alex and Mark.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:40pm UTC](https://forums.powershell.org/t/add-ad-users-info/6801/8 "2024-05-16T20:40:50Z")

</div>


