Here is the task for today to use [easyazon_link identifier=”1787122042″ locale=”US” tag=”wn0d5-20″] PowerShell [/easyazon_link]. I was asked to find the list of employees under a specific manager. In [easyazon_link identifier=”1449361420″ locale=”US” tag=”wn0d5-20″] Active Directory [/easyazon_link] you can retrieve this information under the property DirectReports
Here is the one liner that will help you to get the information from Active Directory:
Get-ADUser -Identity **MANAGER** -Properties directreports | select-object -ExpandProperty DirectReports
or you can add more lines :
1 2 3 4 5 6 7 8 9 | Clear-host Import-Module ActiveDirectory Write-Host . LIST DIRECT REPORTS . -ForegroundColor white -BackgroundColor red Write-Host $Manager = Read-Host [ Enter Manager User Name ] Write-Host Write-Host ... These are Direct Reports to $Manager -ForegroundColor yellow Write-Host Get-ADUser -Identity $Manager -Properties directreports | select-object -ExpandProperty DirectReports |
Here we go now you can get list of all DirectReports employees to given Manager from Active Directory.