[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2013-06-24
7
Medium Priority
?
10,284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 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
2
 

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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

656 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