Hi @Rising Flight ,
the file only contains one column with the email-address?
If so, delete the first line (header) and try this please:
******@contoso.com
******@contoso.com
$emailAddresses = Get-Content C:\temp\listcsv # Import-csv isn't required because it's only one column in the file
ForEach ($emailAddress in $emailAddresses) {
Get-ADUser -Filter { mail -like $emailAddress } -Properties * | Select-Object samaccountname, displayname, UserPrincipalName |
Export-Csv C:\temp\output.csv -NoType -Append
}
If there are more columns in the csv please try this:
emailAddress
******@contoso.com
******@contoso.com
$emailAddresses = Import-Csv C:\temp\listcsv
ForEach ($emailAddress in $emailAddresses) {
Get-ADUser -Filter { mail -like $emailAddress.emailAddress } -Properties * | Select-Object samaccountname, displayname, UserPrincipalName |
Export-Csv C:\temp\output.csv -NoType -Append
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten