Powershell: Output displayname of "Manager" attribute when querying Active Directory

I'm trying to pull a report from Active Directory for which I am including the manager attribute.  As Active Directory stores the DN of the manager in this attribute, that's what I get in my report.

As I understand it, Powershell has a means to perform calculated properties when piping to the Select-Object cmdlet.  Can you use this to translate the manager name to its displayname by running a subsequent Get-ADUser?

I'm looking for something like the following, but I just can't get the syntax down correctly.  

Get-ADUser <params snipped> | Select-Object Name, @{n="ManagerName";e={Get-ADUser -Identity $_.Manager}}

Is this possible?  Am I just messing up the syntax?  I am having a very difficult time in searching online for how to accomplish something like this.
mcdonamw79Asked:
Who is Participating?
 
SubsunCommented:
Try..
Get-ADUser <params snipped> -Properties Manager | Select-Object Name, @{n="ManagerName";e={(Get-ADUser -Identity $_.Manager -properties DisplayName).DisplayName}}

Open in new window

Need to add  -Properties Manager to Get-ADUser
2
 
mcdonamw79Author Commented:
Actually part of my snipped parameters were -Properties * so I had the Manager included.

BTW, I just ran your command and it did not work.  I got a blank value for ManagerName but I fixed it.  I need to add -Properties DisplayName on the manager side of the query.

Get-ADUser <params snipped> -Properties Manager | Select-Object Name, @{n="ManagerName";e={(Get-ADUser -Identity $_.Manager -Properties displayName).DisplayName}}

Thanks for your quick help!
0
 
SubsunCommented:
I have the same command which you posted here.. I think you copied the command before I updated it.. :-)
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
mcdonamw79Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for mcdonamw79's comment #a39271876
Assisted answer: 500 points for Subsun's comment #a39271827

for the following reason:

Using Subsun's reply I formulated the correct answer.
0
 
mcdonamw79Author Commented:
Subsun corrected his answer while I was typing my own solution.  Please reject my answer and set Subsun's reply to be sole answer.  Thank you!
0
 
mcdonamw79Author Commented:
Looks like I had the ability to re-choose the answer.  I'm still pretty new to Experts-Exchange formalities.  Thanks Subsun!
0
 
SubsunCommented:
No worries... I am glad that you are able to fix the issue.. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.