I'm trying to import a csv of sam account names and then check AD to see if they exists. Currently when the program runs it tells me that none of the users in the csv are in AD, "'@{user=joe}' does not exist in AD"; Joe does exist. The only thing that populates the results.csv is the following:
TYPE System.String
Length 34
Import-Module ActiveDirectory
ForEach ($user in Import-Csv 'C:\users2.csv')
{
$list = Get-Aduser -Filter "sAMAccountName -eq '$user'"
If ($list -eq $Null) {"'$user' does not exist in AD"}
else {"User found in AD '$user'" |
Export-Csv 'C:\results.csv' }
}
Aucun commentaire:
Enregistrer un commentaire