Query for all direct and indirect reports?

Hey all,
Looking for a way to easily query for identities who ultimately roll up to a specific manager, even if the manager isn’t their direct manager. For example:

  • Cranky Kong
    • Donkey Kong
      • Diddy Kong
      • Dixie Kong
    • Lanky Kong
      • Chunky Kong
      • Tiny Kong
      • Kiddy Kong
  • Kamek
    • Bowser
      • Ludwig von Koopa
        • Morton Koopa Jr.
        • Roy Koopa
      • Wendy Koopa
        • Iggy Koopa
        • Lemmy Koopa
        • Larry Koopa
    • Bowser Jr.
      • Shy Guy
      • Koopa Troopa
      • Goomba

I’m looking for a query that only includes the folks that roll up to Kamek, but includes those who report to Kamek’s subordinates as well (so, all of Bowser’s neices and nephews, Shy Guy, Koopa Troopa, and Goomba, in addition to Bowser and Bowser Jr.).

If it matters, the authoritative source here is Workday, but Active Directory has the managers set as well.

I’m affraid you cannot use @identity as nested query - it’s simple to get all direct reports of single manager - just use manager.name:Jerry.Bennett the problem is that then you would need to do something like AND @identity(manager.name:Jerry.Bennett) but it’s not possible so you won’t get indirect reports that way.

This might be easier to do with a PowerShell script if you have access to the AD cmdlets. You can use the get-aduser cmdlet using filters and the -recursive flag should get you what you need.