how to get a reverse without false positives or empty fields?

I have a very small script that use to get a reverse info with a list of users in ADPS…

$csv = Import-csv "C:\My Scripts\list.txt" $error.clear() foreach($User in $csv) { $User = $User.User $User Get-QADUser $User | ft name,DisplayName,Email,PrimarySMTPAddress >> reverse_file.csv }

… the problems come when, the list that some ask me to review doesn’t have the exact info. This make that the result file return me a false positive or in case that the username been ambiguous, it return 2 or more similar results.

How I can do to limit the query only to the value that is in the source file, and in case that the username doesn’t exist write “something”?

$csv = Import-csv "C:\My Scripts\list.txt"
foreach($User in $csv){
$User = $User.User
If ($qad = Get-QADUser $User) {$qad | Select-Object name,DisplayName,
Email,PrimarySMTPAddress | export-csv .\reverse_file.csv} Else {"$user does not exist" | out-file .\no_user_file.txt -append}

If the rest is all the same:

…Select-Object -Unique…

If the list has duplicates, you would do something like this:

foreach($User in $csv | Select User -Unique){