I have a list of users but I don't know each user email domain so I'm just wondering how can I concatenate all the domains from $alldomans at the end of their name one by one and try to find their employeeId.
For example, I'm doing like this right now and this is working but I'll have more than one email domain so I'm just wondering how can I pass the domain from my list one by one and try to find their employee Id?.
$EmployeeId= $policy.name | foreach { (Get-AzureADUser -ObjectId "$($_)@gmail.com").ExtensionProperty.employeeId}
I've tried it like this but still not working for some reason
$allDomains = @(
"gmail.com",
"yahoo.com",
"outlook.com"
"hotmail.com"
)
$EmployeeId= $policy.name | foreach { (Get-AzureADUser -ObjectId "$($_)@$allDomains").ExtensionProperty.employeeId}