For both Exchange 2010
and 2013
you can search by email address by creating a list of email addresses in regex
form separated by |
. Then use -imatch
to match the email addresses you need. Note: This will search both primary and secondary address.
$EmailAddress = [regex]"Username1@Domain.com|Username2@Domain.com|Username3@Domain.com"
Get-DistributionGroupMember -Identity "Marketing USA" | Where { $_.EmailAddresses.SmtpAddress -imatch $EmailAddress }
Then to searching by display name you can all so use regex
in the same way separating the names by |
.
$DisplayName = [regex]"FirstName1 LastName1|FirstName2 LastName2|FirstName3 LastName3"
Get-DistributionGroupMember -Identity "Marketing USA" | Where { $_.DisplayName -imatch $DisplayName }
With this method of filtering you can also do partial searches. If you only put in the first name of the user you will get back all users with that name. The same goes will the email address search.