Hello
I need help putting together a script that will look at one user (Bossman). Get Bossman's direct reports, and Bossman's indirect reports, (recursive) . I need to skip if the account name contains below, and skip if DNS contains below. Then populate these users into "GroupA". I came up with the below script, but i am struggling to put this all together. Any help is greatly appreciated
-and ($_.distinguishedName -notcontains 'Disabled Users - Email Hold') -and ($_.distinguishedName -notcontains 'Svc Accnts')
-and ($.name -notcontains 'admin') -and ($_.name -notcontains 'test')
-and ($.name -notcontains 'Ford') `
-and ($.name -notcontains 'Mustang')
function Get-Reports ([string] $manager) {
$users = Get-ADUser -Filter "manager -eq '$manager'"
if ($users -ne $null){
$users
}
$users | % { Get-Reports $_ }
}
# Usage
(Get-Reports Bossman)