Hi,
We used to use a Microsoft Intune GraphAPI endpoint of:
https://graph.microsoft.com/$graphApiVersion/deviceAppManagement/mobileApps/$ApplicationID/devicestatuses
We used this in a PowerShell script, to get a list of devices that had a specific application/application ID installed.
This was in the Beta channel, but is no longer available. I have found I can use the following instead, as it is what the Intune portal uses to produce the same kind of on screen report:
https://graph.microsoft.com/beta/deviceManagement/reports/getDeviceInstallStatusReport
The issue I have with this compared to the old one, is that the old one had paginated responses, and we could submit multiple calls with the paging link to return all results. The new one I am using does not present server side pagination, so I am instead having to use the "top" and "skip" body properties to iterate through all records that exist.
I am finding that using this method using the code below, is very intermittent at returning all results (sometimes it does, sometimes it only returns a portion of the results before failing):
$Skip = 0
do {
$body = @{
select = @(
"DeviceName"
"UserPrincipalName"
"InstallState"
"DeviceId"
"ErrorCode"
"UserName"
"UserId"
"ApplicationId"
"AppInstallState"
)
skip = $skip
top = "50"
filter = "(ApplicationId eq '$ApplicationID')"
orderBy = @(
)
}
$body = $body | ConvertTo-Json
$GraphAPIReturn = Invoke-RestMethod -Headers @{Authorization = "Bearer $($accesstoken)"} -Uri $GraphAPIResource -Method Post -Body $body -ContentType "application/json"
Write-Host $GraphAPIReturn
$TotalRowCount = $GraphAPIReturn.TotalRowCount
$Skip += 50
Start-Sleep -Milliseconds 500
} while (($Skip - 50) -le $TotalRowCount)
I put in a 500 millisecond delay as I suspect there is some kind of throttling or rate limiting going on during my multiple disparate calls, but this did not help. I also tried upping the "top" property to 999, which I understood to be the max, although I think Intune has its own limit of 50 results.
I have found Intune exposes a reporting endpoint that can be used, but to program using this would be more complex, as I would have to;
- Make a request to start the report
- Make further requests to see if the report has finished
- Download the report
- Extract the report
- Parse the report into a PS object
I am therefore left with several questions;
- Is there a different Intune Graph API endpoint I should be using, in place of the first one mentioned in this post, that is not the one I found? I have been unable to locate such an endpoint in the documentation.
- What could be the reason(s) for my intermittently reliable requests using the new endpoint? My assumption is a call or rate limit of some kind to the graph API.
- Does Intune Graph API have a page size limit of 50 only?
- Should the new endpoint I am querying be able to be paginated?
- Is Microsoft's expectation that we should instead now be using the reporting endpoint to produce a downloadable report instead?