I have a for loop that loops through a list of emails and runs this query against our AzureAD using the filter function from MS docs (https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0).
However, any names that have a ' in their name, like bob.o'[email protected] cause the filter to fail. How do i escape the ' in the variable while using it in the filter?
foreach($emailin $emails){
$user_serach = (Get-AzureADUser -Filter "userPrincipalName eq '$email'") # this fails for bob.o'[email protected]
}