Hi,
Suppose you have an array of displaynames $displaynames, then you can do something like the following
$displaynames = ’dn1‘,'dn2','dn3'
foreach($displayname in $displaynames)
{
Get-ADUser -Filter {displayname -eq $displayname} -Properties EmailAddress | Format-table Name,SamAccountName,EmailAddress -AutoSize
}
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.