Why does Powershell say that a supported operator is not supported?
I have the following (simplified) code containing a case-sensitive not-equal operator:
$filter_accountchanged = { (sAMAccountName -eq $username) -and (GivenName -cne $givenname) }
try {
if (Get-ADUser -filter $filter_accountchanged) { # update aduser }
catch {
Write-host $_.Exception
In what situations can this result in the following error that I am seeing?
Microsoft.ActiveDirectory.Management.ADFilterParsingException: Error parsing query: ' (sAMAccountName -eq $username) -and ((GivenName -cne $givenname))' Error Message: 'Operator Not supported: -cne' at position: '50'. at Microsoft.ActiveDirectory.Management.QueryParser.yyparse() at Microsoft.ActiveDirectory.Management.QueryParser..ctor(String query, VariableExpressionConverter varExpressionConverter, ConvertSearchFilterDelegate searchFilterConverterDelegate) at Microsoft.ActiveDirectory.Management.Commands.ADGetCmdletBase`3.BeginProcessingOverride()
The query succeeds when I remove the c
from cne
.