Last active
January 20, 2021 16:11
-
-
Save dpo007/de42885e54fe60a087f62b8c77110d76 to your computer and use it in GitHub Desktop.
PowerShell :: Create simple CSV of AD users with reports (aka Managers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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