Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-AzADUser with advanced queries not working #16874

Closed
erwinkramer opened this issue Jan 19, 2022 · 13 comments · Fixed by #19308 or #19337
Closed

Get-AzADUser with advanced queries not working #16874

erwinkramer opened this issue Jan 19, 2022 · 13 comments · Fixed by #19308 or #19337
Assignees
Labels
AAD AzAd cmdlets in Az.Resources customer-reported feature-request This issue requires a new behavior in the product in order be resolved.

Comments

@erwinkramer
Copy link
Contributor

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
@erwinkramer erwinkramer added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jan 19, 2022
@ghost ghost added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jan 19, 2022
@dingmeng-xue
Copy link
Member

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 dingmeng-xue added AAD AzAd cmdlets in Az.Resources Service This issue points to a problem in the service. and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Jan 19, 2022
@erwinkramer
Copy link
Contributor Author

@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

@dingmeng-xue
Copy link
Member

It's not the reason. You can try it via website https://developer.microsoft.com/en-us/graph/graph-explorer

@dingmeng-xue dingmeng-xue added the needs-author-feedback More information is needed from author to address the issue. label Jan 27, 2022
@JustinGrote
Copy link

JustinGrote commented Feb 1, 2022

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.

image

@dingmeng-xue
Copy link
Member

@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
Copy link

JustinGrote commented Feb 3, 2022

@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": {......}
    }
}

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

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 10, 2022
@ghost
Copy link

ghost commented Feb 10, 2022

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!

@JustinGrote
Copy link

Still an issue.

@ghost ghost removed the no-recent-activity There has been no recent activity on this issue. label Feb 10, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 18, 2022
@ghost
Copy link

ghost commented Feb 18, 2022

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!

@JustinGrote
Copy link

@dingmeng-xue still an issue.

@ghost ghost removed the no-recent-activity There has been no recent activity on this issue. label Feb 18, 2022
@dingmeng-xue dingmeng-xue removed the needs-author-feedback More information is needed from author to address the issue. label Feb 18, 2022
@Mrkokoo
Copy link

Mrkokoo commented Aug 2, 2022

I'm also running to same issue with Get-AzADUser cmdlet. Any estimates on fix timeline?

@VeryEarly VeryEarly added feature-request This issue requires a new behavior in the product in order be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service This issue points to a problem in the service. labels Aug 3, 2022
@VeryEarly
Copy link
Collaborator

We will expose parameter: "Count" in 2022-09-06 release

@VeryEarly VeryEarly added this to the September 2022 (2022-09-06) milestone Aug 3, 2022
@erwinkramer
Copy link
Contributor Author

Thanks, this works now: Get-AzADUser -select 'Department' -AppendSelected -consistencyLevel eventual -Filter "Department ne null" -Count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAD AzAd cmdlets in Az.Resources customer-reported feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
5 participants