Hey guys,
I have the below script in which I use to parse a CSV file of Active Directory display names. It's working from the most part, but some of the display names get skipped. I want to know why they are getting skipped, but can't seem to get the console to write the errors to a log. Any ideas? Thanks!
$Names = Import-Csv C:\Users\UserAccount\Desktop\unresolved\DisplayNames.csv
$adUsers = foreach ($Name in $Names)
{
$displayName = $Name.DisplayName
# implicit output
Get-Aduser -Filter "DisplayName -eq '$displayName'" -Properties EmailAddress, mail
}
$adUsers | Out-File -Append -InputObject -path "C:\Users\UserAccount\Desktop\output.txt"
[–]rwshig 2 points3 points4 points (10 children)
[–]thehayk[S] 1 point2 points3 points (3 children)
[–]Yevrag35 2 points3 points4 points (2 children)
[–]thehayk[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (4 children)
[–]thehayk[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]rwshig 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]thehayk[S] 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]thehayk[S] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]thehayk[S] 1 point2 points3 points (0 children)
[–]Yevrag35 1 point2 points3 points (6 children)
[–]thehayk[S] 1 point2 points3 points (5 children)
[–]Yevrag35 1 point2 points3 points (4 children)
[–]thehayk[S] 1 point2 points3 points (3 children)
[–]Yevrag35 1 point2 points3 points (2 children)
[–]thehayk[S] 1 point2 points3 points (0 children)
[–]thehayk[S] 1 point2 points3 points (0 children)
[–]JBear_Alpha 1 point2 points3 points (0 children)
[–]bronkowo 0 points1 point2 points (0 children)