Skip to content

Instantly share code, notes, and snippets.

@dpo007
Last active January 20, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/de42885e54fe60a087f62b8c77110d76 to your computer and use it in GitHub Desktop.
Save dpo007/de42885e54fe60a087f62b8c77110d76 to your computer and use it in GitHub Desktop.
PowerShell :: Create simple CSV of AD users with reports (aka Managers)
$users = Get-ADUser -Server $DomainController -Filter * -Properties Name, DirectReports
foreach ($user in $users) {
$name = $user.Name
foreach ($report in $user.DirectReports) {
write-output (("$name, $report").Replace("CN=","") -replace ",OU=.*", "") >> c:\temp\ReportsByUser.csv
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment