Help with expression

I am using a simple line of PS to pull a list of users display names and their employee ID's, along with an expression to get their managers display names.  Is there an easy way to modify the expression to pull the manager's name AND manager's employee ID?  We use ExtensionAttribute10 for the employee id.  

My PS is 

Get-ADUser -SearchBase "OU=blah - Internal,DC=blah-corp,DC=com" -filter * -properties * | select DisplayName,ExtensionAttribute10,@{Name='Manager';Expression={(Get-ADUser $_.Manager).name }} 
Can I create a second expression in that line or am I on the wrong track
April 28th, 2015 6:27pm

Hi Eric,

To add the Employid of the manager to the output, please refer to the script below:

Get-ADUser -filter * -properties * | 
select DisplayName,ExtensionAttribute10,@{Name='Manager';Expression={(Get-ADUser $_.Manager).name }},@{Name='ManagerEmployeeID';Expression={Get-ADUser $_.Manager -Properties *|select -ExpandProperty employeeid}}  

To format the output, you can also refer to the "PSObject":

New-Object PSObject Property [HashTable]

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna Wang


Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 10:51pm

y'all please learn to format your lines:

Get-ADUser -filter * -properties * | 
   select DisplayName,
          ExtensionAttribute10,
          @{N='Manager';E={(Get-ADUser $_.Manager).name }},
          @{N='ManagerEmployeeID';E={(Get-ADUser $_.Manager -Properties employeeid).employeeid}}


Of course most of your request does not match the code posted.

April 28th, 2015 11:03pm

Thanks Anna!  Worked perfectly!
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 11:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics