# What am I missing  with this?

**URL:** <https://forums.powershell.org/t/what-am-i-missing-with-this/12285>\
**Category:** PowerShell Help\
**Created:** [March 28, 2019, 10:22am UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285 "2019-03-28T10:22:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tknouse](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@tknouse](https://forums.powershell.org/u/tknouse)\
**Post date:** [March 28, 2019, 10:22am UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/1 "2019-03-28T10:22:18Z")

</div>

Simple:

Trying to pull from a csv file with User.Names (AD) using the import-csv. with one column and no headers ( although I could add them )

Then I’m trying this:

```
Get-ADUser -Properties manager,displayname | select displayName,@{name='userID';expression={$_.name}},@{name='Division';expression={$_.department}},@{name='Manager';expression={ ([ADSI]"LDAP://$($_.manager)").displayname }}
$userData | Export-Csv -Path C:\Users\knouset\Documents\Scripts\managerlist.csv -NoTypeInformation
```

No I am aware the Get-ADuser is not defined above. If I use the “get-adser User.Name” I get the intended output.

&nbsp;

So what I would like to do is combine these and have the users pulled from the names.csv then output to the manager list.

&nbsp;

Im fairly novice to power shell and trying to expand my knowledge, I did a search but didnt find anything specially for this. If its there I apologixwe in advance and please link it to me if I missed it.

&nbsp;

Thanks

Topher

&nbsp;

---

<div class="post-metadata">

**Author:** ![tknouse](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@tknouse](https://forums.powershell.org/u/tknouse)\
**Post date:** [March 28, 2019, 10:33am UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/2 "2019-03-28T10:33:24Z")

</div>

AS a side note:

&nbsp;

I did try the following:

```
$UserData = Import-CSV -Path C:\Users\Folder\Documents\Scripts\names.csv 
foreach ($Users in $UserData)
{
Get-ADUser -Properties manager,displayname | select displayName,@{name='userID';expression={$_.name}},@{name='Manager';expression={ ([ADSI]"LDAP://$($_.manager)").displayname }}
}
$userData | Export-Csv -Path C:\Users\Folder\Documents\Scripts\managerlist.csv -NoTypeInformation
```

Although, I am still missing something.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![pwshliquori](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/pwshliquori/32/222_2.png) [@pwshliquori](https://forums.powershell.org/u/pwshliquori)\
**Post date:** [March 28, 2019, 11:59am UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/3 "2019-03-28T11:59:48Z")

</div>

Hi toknouse43,

In your scripts, specifically, `@{name=‘userID’;expression={$_.name}}` that return the display name of the user. If you need the username of the user, you should use the SamAccountName property. Also, using the Import-Csv returns an object which requires headers to import the data.

pwshliquori

---

<div class="post-metadata">

**Author:** ![tknouse](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@tknouse](https://forums.powershell.org/u/tknouse)\
**Post date:** [March 28, 2019, 12:27pm UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/4 "2019-03-28T12:27:37Z")

</div>

pwshliquori

&nbsp;

Thank you. I’m about to go work on these

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [March 28, 2019, 2:25pm UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/5 "2019-03-28T14:25:36Z")

</div>

```
get-content names.txt | get-aduser
```

---

<div class="post-metadata">

**Author:** ![nitbha](https://avatars.discourse-cdn.com/v4/letter/n/6a8cbe/32.png) [@nitbha](https://forums.powershell.org/u/nitbha)\
**Post date:** [June 2, 2019, 7:57pm UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/6 "2019-06-02T19:57:04Z")

</div>

@[tknouse43](https://powershell.org/profile/tknouse/)

try below code it will work for you …  
Get-ADUser we have a mandiory field that is “Filter” parameter which needs to pass or put \* that was missing your code.

**Code:**  
Get-ADUser -Filter \* -Properties manager,DisplayName,name | select DisplayName,@{name=‘UserID’;expression={$_.name}},@{name=‘Manager’;expression={ ([ADSI]"LDAP://$($_.manager)").displayname }} | export-csv -Path C:\Users\Folder\Documents\Scripts\managerlist.csv -NoTypeInformation

Chrees !!!  
Nitesh

&nbsp;

---

<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:32pm UTC](https://forums.powershell.org/t/what-am-i-missing-with-this/12285/7 "2024-05-16T20:32:40Z")

</div>


