Roccat
asked on
apostrophe causing issues with get-aduser
I have a list of users in a list box. One of the users has an apostrophe in their name and it causes error. I know I can escape an apostrophe with another apostrophe but the list is loaded from the ad from members of a security group and they are loaded into the list as is with the one apostrophe. What can I do to allow the get-aduser to complete with a user with an apostrophe in their name?
$listboxselection = "Larry O'Reilly"
$a = Get-Aduser -Filter "displayname -eq '$listboxselection'" -Property displayname
Remove-ADGroupMember "Coaches" -Members $a -confirm:$false
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER