Escaping strings containing single quotes in PowerShell

Iron Contributor

Hi there,

How can i replace the single quote in the name cai.o'dowd as its causing errors


string is




Currently i'm doing the below and filtering based on userprinciplename



ObjectuserId = (Get-AzureADUser -Filter "UserPrincipalName eq '$($User.LoginName.replace('i:0#.f|membership|',''))'").ObjectId


Any ideas how i can do this in PowerShell?
I would also like to check if the field is null before processing it


Thanks in Advance


0 Replies