
Getting app status reports using the Microsoft Graph API
I like statistics, especially when they relate to Microsoft Intune. I like to receive detailed overviews about my Microsoft 365 tenant and the install status of Win32 apps. If I can generate these reports using Azure DevOps Pipelines, the Graph API, and PowerShell, I am sold.
Recently, I had a need to report the successful install status of Win32 apps. I quickly stumbled across a Microsoft Learn article that gave me the API endpoints to query this data. However, the given endpoints to query the data (“List mobileAppInstallStatuses,” “deviceStatuses,” and “userStatuses”) didn’t seem to respond as expected, and I received the error: “BadRequest, Resource not found for the segment ‘deviceStatuses’.” It seemed Microsoft had changed the endpoints back in 2023 and did not update the documentation on Learn, but they did post an interesting update on the Microsoft Intune blog.
Armed with this new knowledge, I came up with a code snippet that allows you to get the status of an Intune Win32 app. You can use my code snippet below and expand on it.
$uri = "https://graph.microsoft.com/beta/deviceManagement/reports/getAppStatusOverviewReport"
# Replace {appid} with the Id of your Intune Win32-App
$body = @{filter = "(ApplicationId eq '{appid}')"}
$results = Invoke-MgGraphRequest -Uri $uri -Method POST -Body $body -OutputType HttpResponseMessage
$bytes = $results.Content.ReadAsByteArrayAsync().Result
$status = [System.Text.Encoding]::UTF8.GetString($bytes)Once the content is retrieved we can convert it to a JSON and extract the values.
$uri = "https://graph.microsoft.com/beta/deviceManagement/reports/getAppStatusOverviewReport"
# Replace {appid} with the Id of your Intune Win32-App
$body = @{filter = "(ApplicationId eq '{appid}')"}
$results = Invoke-MgGraphRequest -Uri $uri -Method POST -Body $body -OutputType HttpResponseMessage
$bytes = $results.Content.ReadAsByteArrayAsync().Result
$json = [System.Text.Encoding]::UTF8.GetString($bytes) | ConvertFrom-Json
$columns = $json.Schema.Column
foreach ($value in $json.Values) {
$appStatus = @{}
for ($i = 0; $i -lt $columns.Count; $i++) {
$appStatus[$columns[$i]] = $value[$i]
}
}This will result in a variable called $appStatus which will contain the app status overview report.
# The value of $appStatus
Name Value
---- -----
PendingInstallUserCount 0
NotInstalledDeviceCount 0
PendingInstallDeviceCount 0
InstalledUserCount 10
ApplicationId 00000000-0000-0000-0000-000000000000
FailedUserCount 0
NotApplicableDeviceCount 3
FailedDeviceCount 0
NotInstalledUserCount 0
NotApplicableUserCount 0
InstalledDeviceCount 17