Skip to content

Commit 8b4f760

Browse files
stgrdkdavefalkus
authored andcommitted
Added Get-DeviceStatusForApp function (#122)
I have added an extra function that gets all devices and their install status that are assigned to an application
1 parent c6849c6 commit 8b4f760

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

Applications/Application_InstallStats.ps1

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Function Get-InstallStatusForApp {
216216
.SYNOPSIS
217217
This function will get the installation status of an application given the application's ID.
218218
.DESCRIPTION
219-
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.
219+
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.
220220
.EXAMPLE
221221
Get-InstallStatusForApp -AppId a1a2a-b1b2b3b4-c1c2c3c4
222222
This will return the installation status of the application with the ID of a1a2a-b1b2b3b4-c1c2c3c4
@@ -263,6 +263,59 @@ param
263263

264264
####################################################
265265

266+
Function Get-DeviceStatusForApp {
267+
268+
<#
269+
.SYNOPSIS
270+
This function will get the devices installation status of an application given the application's ID.
271+
.DESCRIPTION
272+
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.
273+
.EXAMPLE
274+
Get-DeviceStatusForApp -AppId a1a2a-b1b2b3b4-c1c2c3c4
275+
This will return devices and their installation status of the application with the ID of a1a2a-b1b2b3b4-c1c2c3c4
276+
.NOTES
277+
NAME: Get-DeviceStatusForApp
278+
#>
279+
280+
[cmdletbinding()]
281+
282+
param
283+
(
284+
[Parameter(Mandatory=$true)]
285+
[string]$AppId
286+
)
287+
288+
$graphApiVersion = "Beta"
289+
$Resource = "deviceAppManagement/mobileApps/$AppId/deviceStatuses"
290+
291+
try
292+
{
293+
294+
$uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)"
295+
(Invoke-RestMethod -Uri $uri -Headers $authToken -Method Get).Value
296+
297+
}
298+
299+
catch
300+
{
301+
302+
$ex = $_.Exception
303+
$errorResponse = $ex.Response.GetResponseStream()
304+
$reader = New-Object System.IO.StreamReader($errorResponse)
305+
$reader.BaseStream.Position = 0
306+
$reader.DiscardBufferedData()
307+
$responseBody = $reader.ReadToEnd();
308+
Write-Host "Response content:`n$responseBody" -f Red
309+
Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)"
310+
write-host
311+
break
312+
313+
}
314+
315+
}
316+
317+
####################################################
318+
266319
#region Authentication
267320

268321
write-host

0 commit comments

Comments
 (0)