diff --git a/Applications/Application_InstallStats.ps1 b/Applications/Application_InstallStats.ps1 index 54e93c6..7933059 100644 --- a/Applications/Application_InstallStats.ps1 +++ b/Applications/Application_InstallStats.ps1 @@ -216,7 +216,7 @@ Function Get-InstallStatusForApp { .SYNOPSIS This function will get the installation status of an application given the application's ID. .DESCRIPTION -If you want to track your managed intune application installaion stats as you roll them out in your environment, use this commandlet to get the insights. +If you want to track your managed intune application installation stats as you roll them out in your environment, use this commandlet to get the insights. .EXAMPLE Get-InstallStatusForApp -AppId a1a2a-b1b2b3b4-c1c2c3c4 This will return the installation status of the application with the ID of a1a2a-b1b2b3b4-c1c2c3c4 @@ -263,6 +263,59 @@ param #################################################### +Function Get-DeviceStatusForApp { + +<# +.SYNOPSIS +This function will get the devices installation status of an application given the application's ID. +.DESCRIPTION +If you want to track your managed intune application installation stats as you roll them out in your environment, use this commandlet to get the insights. +.EXAMPLE +Get-DeviceStatusForApp -AppId a1a2a-b1b2b3b4-c1c2c3c4 +This will return devices and their installation status of the application with the ID of a1a2a-b1b2b3b4-c1c2c3c4 +.NOTES +NAME: Get-DeviceStatusForApp +#> + +[cmdletbinding()] + +param +( + [Parameter(Mandatory=$true)] + [string]$AppId +) + + $graphApiVersion = "Beta" + $Resource = "deviceAppManagement/mobileApps/$AppId/deviceStatuses" + + try + { + + $uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)" + (Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).Value + + } + + catch + { + + $ex = $_.Exception + $errorResponse = $ex.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($errorResponse) + $reader.BaseStream.Position = 0 + $reader.DiscardBufferedData() + $responseBody = $reader.ReadToEnd(); + Write-Host "Response content:`n$responseBody" -f Red + Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)" + write-host + break + + } + +} + +#################################################### + #region Authentication write-host