Solved

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

Posted on 2013-06-24
7
7,544 Views
Last Modified: 2013-06-24
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.
0
Comment
Question by:mcdonamw79
  • 4
  • 3
7 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39271827
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
1
 

Author Comment

by:mcdonamw79
ID: 39271876
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
 
LVL 40

Expert Comment

by:Subsun
ID: 39271883
I have the same command which you posted here.. I think you copied the command before I updated it.. :-)
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:mcdonamw79
ID: 39271896
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
 

Author Comment

by:mcdonamw79
ID: 39271893
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
 

Author Comment

by:mcdonamw79
ID: 39271903
Looks like I had the ability to re-choose the answer.  I'm still pretty new to Experts-Exchange formalities.  Thanks Subsun!
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39271908
No worries... I am glad that you are able to fix the issue.. :-)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now