Solved

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

Posted on 2013-06-24
7
7,967 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html) provided 218 attendees with a step-by-step guide for identifying Acti…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 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