Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion Applications/Application_InstallStats.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down