In part of my script I am trying to query AD Searching by employee number. This works fine for 90% of the employees. however in my organization we have a few special employees where the employee number contains letters thus breaking my powershell command.
here are 2 examples
Get-ADUser -Filter "EmployeeID -eq 12345" -Properties SAMAccountName
Get-ADUser -Filter "EmployeeID -eq ABC1234567" -Properties SAMAccountName
The first option works fine but the second one fails.
Get-ADUser : Error parsing query: 'EmployeeID -eq ABC1234567' Error Message: 'syntax error' at position: '16'. At line:1 char:1 + Get-ADUser -Filter "EmployeeID -eq ABC1234567" -Properties SAMAccou ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Micr osoft.ActiveDirectory.Management.Commands.GetADUser