Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Recursively select all subordinates for all users from AD

$
0
0

I'd like to use AD to maintain a list of a user's subordinates, which will be used in a custom application to control the display of information.  Currently, this list is manually maintained, and it would be a lot easier if we could rely on AD for this.

Is there a way to recursively select all users and all of their subordinates (direct reports as well as direct report of direct reports) from Active Directory using PowerShell (or something else)?

The example org structure is:

1. President
  2. VP 1
    3. Team Member 1
    3. Team Member 2
  2. VP 2
    3. Team Member 3
    3. Team Member 4

I would like to get a csv file that contains the username of the manager and the username of their subordinates.  In this example:

MANAGER,SUBORDINATE
president, vp1
president, team1
president, team2
president, vp2
president, team3
president, team4
vp1, team1
vp1, team2
vp2, team3
vp2, team4
The levels of nesting can obviously vary, but I'd like it to go as deep as it need to in order to capture all levels and provide the output.  


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>