azure-powershell
azure-powershell copied to clipboard
Get-AzADUser with advanced queries not working
Description
If i understand correctly, the following advanced query should work because i set consistencyLevel eventual:
Get-AzADUser -select 'Department' -AppendSelected -consistencyLevel eventual -Filter "Department ne null"
Documentation: https://docs.microsoft.com/en-us/graph/aad-advanced-queries#support-for-filter-on-properties-of-azure-ad-directory-objects
Issue script & Debug output
Get-AzADUser -select 'Department' -AppendSelected -consistencyLevel eventual -Filter "Department ne null"
Get-AzADUser_List:....\PowerShell\Modules\Az.Resources\5.2.0\MSGraph.Autorest\custom\Get-AzADUser.ps1:210
Line |
210 | Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unsupported property filter clause operator 'NotEqualsMatch'.
Environment data
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.7.1 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script 2.3.1 Az.ApiManagement {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagementProductToGroup, Add-AzApiManagementRegion…}
Script 5.2.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
Error output
Message : [Request_UnsupportedQuery] : Unsupported property filter clause operator 'NotEqualsMatch'.
StackTrace :
Exception : System.Exception
InvocationInfo : {Get-AzADUser_List}
Line : Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
Position : At C:\Users\ekramer\Documents\PowerShell\Modules\Az.Resources\5.2.0\MSGraph.Autorest\custom\Get-AzADUser.ps1:210 char:9
+ Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 127
It seems a service bug. Its behavior is different from documentation. I use the example on doc and send request to service directly
# Works
GET https://graph.microsoft.com/v1.0/users?companyName ne null
# Doesn't work
GET https://graph.microsoft.com/v1.0/users?$filter=companyName ne null
#works
https://graph.microsoft.com/v1.0/users?$filters=companyName ne null
I seems filters support it but API spec doesn't mention that query parameter
https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/2d2ce81e3f093a9c6e8642beac37c868017b9c63/openApiDocs/v1.0/Users.yml#L28
@dingmeng-xue the documentation specifies that the count parameter should be included too, maybe that's what is missing, it should be added by default when you call the Az.Resources module with a filter like that.
these advanced query capabilities are not available by default but, the requestor must also set the ConsistencyLevel header to eventual and, with the exception of $search, use the $count query parameter. The ConsistencyLevel header and $count are referred to as advanced query parameters.
https://docs.microsoft.com/en-us/graph/aad-advanced-queries
It's not the reason. You can try it via website https://developer.microsoft.com/en-us/graph/graph-explorer
It absolutely requires the $count parameter but there's no way in the current parameters to do this short of a convoluted httppipelineprepend. In the graph SDK there is a -countvariable parameter that sets $count and returns the count to that set variable, these Az commands should replicate that behavior.

@JustinGrote , According to API spec of MSGraph, count is not required parameter.
When I tried GET https://graph.microsoft.com/v1.0/users?$filter=Department%20ne%20null&$count=true, I got
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported property filter clause operator 'NotEqualsMatch'.",
"innerError": {......}
}
}
@JustinGrote , According to API spec of MSGraph,
countis not required parameter.When I tried
GET https://graph.microsoft.com/v1.0/users?$filter=Department%20ne%20null&$count=true, I got{ "error": { "code": "Request_UnsupportedQuery", "message": "Unsupported property filter clause operator 'NotEqualsMatch'.", "innerError": {......} } }
Your query is not the same as my query. You did a ne filter, not an eq filter, you did it on department not company, and it is also not clear if you specified ConsistencyLevel eventual header. You need both the header and count for advanced queries
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!
Still an issue.
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!
@dingmeng-xue still an issue.
I'm also running to same issue with Get-AzADUser cmdlet. Any estimates on fix timeline?
We will expose parameter: "Count" in 2022-09-06 release
Thanks, this works now: Get-AzADUser -select 'Department' -AppendSelected -consistencyLevel eventual -Filter "Department ne null" -Count