locked
Recursively output name and manager details RRS feed

  • Question

  • Dear Experts,

    The following cmdlet gives out the name and manager details of all the direct reportees of a given manager 'manager1' . Could you please direct me how can we make it run recursively so that it gives the details underneath it? Thanks.


    Get-ADUser -Identity manager1 -Properties directreports | Select-Object -ExpandProperty DirectReports | Get-ADUser -Properties  manager | select name, @{Name = 'Manager'; Expression = {(Get-ADUser $_.Manager).Name}} 



    • Edited by jrprakash Wednesday, February 19, 2020 3:30 AM
    Wednesday, February 19, 2020 3:30 AM

Answers

  • Example in the Gallery:

    https://gallery.technet.microsoft.com/Document-Active-Directory-47486cf5

    The TechNet Gallery seems to be read-only now, and the html is a bit messed up, but the link to download the script should work. Running the script with the /help switch gives help informaton for options to use, but there are defaults for things like output format.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by jrprakash Wednesday, February 26, 2020 12:34 AM
    Wednesday, February 19, 2020 9:28 PM

All replies

  • If you look in the Gallery you will find code that does what you ask.

    \_(ツ)_/

    Wednesday, February 19, 2020 9:23 AM
  •  . . . or Google/Bing "powershell org chart". There's plenty of stuff to work with.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Wednesday, February 19, 2020 8:55 PM
  • Example in the Gallery:

    https://gallery.technet.microsoft.com/Document-Active-Directory-47486cf5

    The TechNet Gallery seems to be read-only now, and the html is a bit messed up, but the link to download the script should work. Running the script with the /help switch gives help informaton for options to use, but there are defaults for things like output format.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by jrprakash Wednesday, February 26, 2020 12:34 AM
    Wednesday, February 19, 2020 9:28 PM