Hi,
Please check to see if this works.
$input = "C:\temp\input.csv"
$output = "C:\temp\output.csv "
Import-Csv -Path $input | ForEach-Object {
$mail = $_.user
Get-ADUser -Filter {EmailAddress -eq $mail} -Properties DisplayName, EmailAddress |
Select-Object -Property DisplayName, SamAccountName,UserPrincipalName, EmailAddress
} | Export-Csv -Path $output -NoTypeInformation
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.