Filter out specific type of policy via Microsoft Graph API
This is a knowledgebase item. Hope it helps you out someday with filter out of a specific policy type like windows Update for Business Configuration profiles or Windows 10 Custom Configuration profiles on device configuration profiles via the Graph API @odata.type property.
To get a subset of the results from the Graph API, we can use the filter command. The $filter query parameter can also be used to retrieve relationships like members, memberOf, transitiveMembers, and transitiveMemberOf.
More information about filters can be found here.
In another knowledgebase item I have explained how to filter on a specific policy type. But sometimes you want all the profiles except a specific one. So, in this KB item I will explain how to exclude a specific type.
Graph API URL
Filtering works fine for almost all properties, but if you want to filter on the @odata.type property, it’s just a little bit different. In my case, I wanted to filter out the Windows Update for Business and Custom Configuration Profiles. I already know it is possible to filter on a specific type but now I wanted to exclude a specific type of policy.
Note. Make sure no hashtag is placed before the profile @odata.type property in the filter.
https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$filter=not(isof('{odata type}'))
For e.g.,
https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$filter=not(isof('microsoft.graph.windows10CustomConfiguration'))+and+not(isof('microsoft.graph.windowsUpdateForBusinessConfiguration'))&$select=id,displayName
Results:
Leave a Reply
Want to join the discussion?Feel free to contribute!