Powershell command/script to list all users who have a given manager.

I need a way to list all the users of a given manager. It can be a native powershell or using QAD tools.

Here is what I tried?

$Mgr = Get-Qaduser MyManager
get-qaduser | where {$_.Manager -eq $Mgr}

But that did not return any results.
LVL 12
Gary DewrellSenior Network AdministratorAsked:
Who is Participating?
Dan ArseneauConnect With a Mentor Commented:

Get-User -ResultSize unlimited | where {$_.manager -match "name"}

Open in new window

I would not use that filter
"Get-User -ResultSize unlimited | where {$_.manager -match "name"}"

What this is doing is pulling every single user in your AD and then piping to the where. If you have a large AD env this will take awhile

Use this

Get-Qaduser -manager USERNAMEOFMANAGER
ANd to add to your original. It was not working becuase it is looking for a DN

SO this would work but very inefficient

$Mgr = (Get-Qaduser MyManager).DN
get-qaduser | where {$_.Manager -eq $Mgr}
Gary DewrellSenior Network AdministratorAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.