Here is the task for today to use PowerShell. I was asked to find the list of employees under a specific manager. In Active Directory 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 :
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.