Home > Blockchain >  MSGraph OData filtering on empty collections
MSGraph OData filtering on empty collections

Time:02-09

I'm using the MS powershell modules for working with MsGraph, but the same rules/principles apply when providing a filter as to what you'd normally just put into the http query string.

I have the following which works okay and lists all 365groups that are teams:

Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')"

What I would like to acheive, without having to pull ALL groups and then filtering locally, is basically the opposite of the above, something like this:

Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x ne 'Team')"

But because I'm doing this against a collection, it throws.

Get-MgGroup_List: Unsupported property filter clause operator 'NotEqualsMatch'.

Now I've tried every which way I an think of to get this to work, I've tried looking for a set of operators that would effectivly filter if resourceProvisioningOptions is null/empty as a collection. But nothing I try will work, I just seem to get errors. Anyone have any ideas?

Thanks, Tom

CodePudding user response:

According to this resourceProvisioningOptions is not nullable and not filterable using null.

ne negation operators are supported only with advanced queries which means that you need to add -ConsistencyLevel "eventual" and -CountVariable or -CountVariable "<number>" (I'm not familiar with Graph API SDK for PowerShell) parameters

Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x ne 'Team')" -ConsistencyLevel "eventual" -CountVariable "100"
  •  Tags:  
  • Related