ugurkocde / IntuneAssignmentChecker

https://intuneassignmentchecker.ugurkoc.de/
MIT License
107 stars 13 forks source link

Not all data is shown #28

Closed FNHagen closed 1 week ago

FNHagen commented 1 week ago

Thanks this is a very nice tool and very useful. However it looks like we don't get all the results we expect. Is there a limitation on retrieving the data? Seems like it might be related to Settings catalog - we only get around 23 of 100+ policies

@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/configurationPolicies", "@odata.count": 25, "@odata.nextLink": "https://graph.microsoft.com/beta/deviceManagement/configurationPolicies? $skiptoken=%255Bcosmosdb%255D%255B%257B%2522compositeTokenxxxxxxxxxxxxxxxxxxx", "@microsoft.graph.tips": "This request only returns a subset of the resource's properties. Your app will need to use $select to return non-default properties. To find out what other properties are available for this resource see [https://learn.microsoft.com/graph/api/resources/deviceManagementConfigurationPolicy"]

ugurkocde commented 1 week ago

Thanks @FNHagen

Can you confirm if you use the latest version (2.4.0)?

Which option is this specifically that you use?

FNHagen commented 1 week ago

Yes, 2.4.0 - and goes for all options that retrieves from setting catalog Ran the 4 - Show All Policies and Their Assignments

the challenge is that not all policies are returned when calling "Invoke-MgGraphRequest -Uri $settingsCatalogUri -Method Get". You get a subset, in our case 25, and a link to the next blob. Not an expert, but think the script will need to detect that there is more data, and repeat the calls until the is no more @odata.nextlink in the returned result

ugurkocde commented 1 week ago

Yea looks like the @odata.nextlink is missing. I will have a look.

FNHagen commented 1 week ago

Seems like this is working for us for the settings catalog part that is.

# Fetch settings catalog policies
$settingsCatalogUri = "https://graph.microsoft.com/beta/deviceManagement/configurationPolicies"
$tempResponse = Invoke-MgGraphRequest -Uri $settingsCatalogUri -Method Get
$response += $tempResponse

if ($tempResponse.'@odata.nextlink') {
    do {
        $tempResponse = Invoke-MgGraphRequest -Uri $tempResponse.'@odata.nextlink' -Method Get
        $response += $tempResponse
    } until (
        !$tempResponse.'@odata.nextlink'
    )
}
ugurkocde commented 1 week ago

I double checked the pagination. There is one missing in a function that I have fixed now.

Can you try it with that one?

https://github.com/ugurkocde/IntuneAssignmentChecker/blob/28-not-all-data-is-shown/IntuneAssignmentChecker_v2.ps1

FNHagen commented 1 week ago

Looks better - I got 103 Settings Catalog - need some time to verify the rest (y)

ugurkocde commented 1 week ago

Awesome. I will merge it to main. Keep the feedback coming if you need any new features or things are not working.

Thanks for taking the time to create this issue.

Best Ugur