Hi All
i have email addresses in csv file, my csv file is in below format. How can i export samaccountname, UPN by importing the email addresses.
user
user1@contoso.com
user2@contoso.com
When i try the below syntax i am getting error
foreach($user in (get-content C:\temp\input.csv){
get-aduser -filter {emailaddress -eq $user} |select -property displayname, samaccountname,UserPrincipalName, emailaddress |
Export-Csv C:\temp\output.csv -NoTypeInformation
}