Skip to content

Commit d29902b

Browse files
committed
show error messages on intune scripts
1 parent d943fc9 commit d29902b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ListIntuneScript.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,19 @@ function Invoke-ListIntuneScript {
4848
}
4949

5050
foreach ($scriptId in @('Windows', 'MacOS', 'Remediation', 'Linux')) {
51-
$scripts = ($BulkResults | Where-Object { $_.id -eq $scriptId }).body.value
51+
$BulkResult = ($BulkResults | Where-Object { $_.id -eq $scriptId })
52+
if ($BulkResult.status -ne 200) {
53+
$Results.Add(@{
54+
'scriptType' = $scriptId
55+
'displayName' = if (Test-Json $BulkResult.body.error.message) {
56+
($BulkResult.body.error.message | ConvertFrom-Json).Message
57+
} else {
58+
$BulkResult.body.error.message
59+
}
60+
})
61+
continue
62+
}
63+
$scripts = $BulkResult.body.value
5264

5365
if ($scriptId -eq 'Linux') {
5466
$scripts = $scripts | Where-Object { $_.platforms -eq 'linux' -and $_.templateReference.templateFamily -eq 'deviceConfigurationScripts' }

0 commit comments

Comments
 (0)