Link to home
Start Free TrialLog in
Avatar of Matthew McDonald
Matthew McDonaldFlag for United States of America

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matthew McDonald

ASKER

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!
I have the same command which you posted here.. I think you copied the command before I updated it.. :-)
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.
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!
Looks like I had the ability to re-choose the answer.  I'm still pretty new to Experts-Exchange formalities.  Thanks Subsun!
No worries... I am glad that you are able to fix the issue.. :-)