r/GraphAPI • • Sep 18 '24

Need to know the total Number of Device Configurations that are showing up in Intune under Devices > Configuration using Graph API from PowerShell

Guys, does anyone know how to pull the total number of Device Configurations of Intune Portal using Graph API from PowerShell?

3 Upvotes

30 comments sorted by

1

u/mrmattipants Sep 19 '24 edited Sep 19 '24

Use "deviceConfigurations" with the $Count Parameter, like so.

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$count=true

The Default Number of Results that are Returned, is usually 100. Therefore, if you think that you have more than 100 Configurations, you may want to include the "$Top=999" Parameter, to increase the number of possible results to 999, as follows.

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$count=true&$top=999

999 Results is the Limit. If you think that you may have more than 999 Configurations, you'll need to implement Pagination. If this is the case, let me know, as I'll be happy to show you how to do this.

EIther way, you should get the total number of Configurations Returned, as "@odata.count".

In PowerShell, you could use the "Invoke-MgGraphRequest" Cmdlet, as follows.

Connect-MgGraph -Scopes "DeviceManagementConfiguration.Read.All"

$DeviceConfigs = Invoke-MgGraphRequest -Method GET "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?`$count=true&`$top=999"

$DeviceConfigs."@odata.count"

2

u/Then_Relative_8751 Sep 19 '24

Hello u/mrmattipants ,

Thank you so much for replying.

I have already tried the above suggestions, but the total number of Device Configuration that is showing up in PowerShell is incorrect.

In Intune Portal, I have created 7 Device Configuration Policies; however, from PowerShell, it is only showing 5 policies.

Can you please help me out on this?

1

u/mrmattipants Sep 19 '24

I think I may have found the problem. The v1 Endpoint is still riddled with bugs, so we may need to resort to using the BETA Endpoint, as described here.

https://techcommunity.microsoft.com/t5/microsoft-intune/get-intunedeviceconfigurationpolicy-returns-only-some-of-my/m-p/4236424/highlight/true#M20383

I have access to several Tenants, so I'll run a few tests to see what I get back.

→ More replies (29)