1

Can anyone please help me with a powershell script to find the NUMBER of direct and indirect reports to a manager from Active Directory. I just need the number of people (details not required)

There are 100s of people in that line of business under that manager. So it is impossible to get a count of them manually.

Thanks

1 Answers1

1

You will need to use a recursive method that looks up all the users that have desired person as the manager. These will give you the direct reports ... easy and quick.

Issue comes up when you want to get the indirect reports as well.. that would require you to check the Direct Reports to each user you get from desired person's Direct Report and further on.

Following method can help you acheive that but keep in mind, it will take longer and longer based on the number of managers you have in that tree.

function Get-Reports ([string] $manager) {
  $users = Get-ADUser -Filter "manager -eq '$manager'"
  if ($users -ne $null){
    $users
  }
  $users | % { Get-Reports $_ }
}

# Usage
(Get-Reports <userID>).Count
Jawad
  • 11,028
  • 3
  • 24
  • 37