Skip to content

Commit 30f151b

Browse files
committed
fix empty defender alert list
1 parent 0514858 commit 30f151b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Security/Invoke-ExecAlertsList.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Function Invoke-ExecAlertsList {
4343
}
4444

4545
$DisplayableAlerts = New-FlatArray $AlertsObj | Where-Object { $null -ne $_.Id } | Sort-Object -Property EventDateTime -Descending
46+
if (!$DisplayableAlerts) {
47+
$DisplayableAlerts = @()
48+
}
49+
$Metadata = [PSCustomObject]@{}
4650

4751
[PSCustomObject]@{
4852
NewAlertsCount = $DisplayableAlerts | Where-Object { $_.Status -eq 'newAlert' } | Measure-Object | Select-Object -ExpandProperty Count
@@ -51,7 +55,7 @@ Function Invoke-ExecAlertsList {
5155
SeverityMediumAlertsCount = $DisplayableAlerts | Where-Object { ($_.Status -eq 'inProgress') -or ($_.Status -eq 'newAlert') } | Where-Object { $_.Severity -eq 'medium' } | Measure-Object | Select-Object -ExpandProperty Count
5256
SeverityLowAlertsCount = $DisplayableAlerts | Where-Object { ($_.Status -eq 'inProgress') -or ($_.Status -eq 'newAlert') } | Where-Object { $_.Severity -eq 'low' } | Measure-Object | Select-Object -ExpandProperty Count
5357
SeverityInformationalCount = $DisplayableAlerts | Where-Object { ($_.Status -eq 'inProgress') -or ($_.Status -eq 'newAlert') } | Where-Object { $_.Severity -eq 'informational' } | Measure-Object | Select-Object -ExpandProperty Count
54-
MSResults = $DisplayableAlerts
58+
MSResults = @($DisplayableAlerts)
5559
}
5660
} else {
5761
$Table = Get-CIPPTable -TableName cachealertsandincidents

0 commit comments

Comments
 (0)