Skip to content

Commit 6dcb159

Browse files
fixes length bug
1 parent 65fb576 commit 6dcb159

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Modules/CIPPCore/Public/New-CIPPAlertTemplate.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ function New-CIPPAlertTemplate {
2222
$Table = ''
2323
$LocationInfo = $LocationInfo ?? $Data.CIPPLocationInfo | ConvertFrom-Json -ErrorAction SilentlyContinue | Select-Object * -ExcludeProperty Etag, PartitionKey, TimeStamp
2424
if ($InputObject -eq 'table') {
25+
#data can be a array of strings or a string, if it is, we need to convert it to an object so it shows up nicely, that object will have one header: message.
26+
if ($Data -is [string]) {
27+
$Data = @{ message = $Data }
28+
}
29+
if ($Data -is [array] -and $Data[0] -is [string]) {
30+
$Data = $Data | ForEach-Object { @{ message = $_ } }
31+
}
2532
$DataHTML = ($Data | Select-Object * -ExcludeProperty Etag, PartitionKey, TimeStamp | ConvertTo-Html | Out-String).Replace('<table>', ' <table class="table-modern">')
2633
$IntroText = "<p>You've configured CIPP to send you alerts based on the logbook. The following alerts match your configured rules</p>$dataHTML"
2734
$ButtonUrl = "$CIPPURL/cipp/logs"

0 commit comments

Comments
 (0)