Skip to content

Commit 000ac0e

Browse files
authored
Merge pull request KelvinTegelaar#1514 from ngms-psh/fix-quaratinepolicy-report
Fix: Quaratine Policy standard report
2 parents b3841e8 + 4d562fa commit 000ac0e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListStandardsCompare.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ function Invoke-ListStandardsCompare {
5050
$FieldName = $Standard.RowKey
5151
$FieldValue = $Standard.Value
5252
$Tenant = $Standard.PartitionKey
53+
54+
# decode field names that are hex encoded (e.g. QuarantineTemplates)
55+
if ($FieldName -match '^(standards\.QuarantineTemplate\.)(.+)$') {
56+
$Prefix = $Matches[1]
57+
$HexEncodedName = $Matches[2]
58+
$Chars = [System.Collections.Generic.List[char]]::new()
59+
for ($i = 0; $i -lt $HexEncodedName.Length; $i += 2) {
60+
$Chars.Add([char][Convert]::ToInt32($HexEncodedName.Substring($i,2),16))
61+
}
62+
$FieldName = "$Prefix$(-join $Chars)"
63+
}
64+
5365
if ($FieldValue -is [System.Boolean]) {
5466
$FieldValue = [bool]$FieldValue
5567
} elseif ($FieldValue -like '*{*') {

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardQuarantineTemplate.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ function Invoke-CIPPStandardQuarantineTemplate {
183183
}
184184

185185
if ($true -in $Settings.report) {
186-
# This could do with an improvement. But will work for now or else reporting could be disabled for now
187186
foreach ($Policy in $CompareList | Where-Object -Property report -EQ $true) {
188-
Set-CIPPStandardsCompareField -FieldName "standards.QuarantineTemplate" -FieldValue $Policy.StateIsCorrect -TenantFilter $Tenant
187+
# Convert displayName to hex to avoid invalid characters "/, \, #, ?" which are not allowed in RowKey, but "\, #, ?" can be used in quarantine displayName
188+
$HexName = -join ($Policy.displayName.ToCharArray() | ForEach-Object { '{0:X2}' -f [int][char]$_ })
189+
Set-CIPPStandardsCompareField -FieldName "standards.QuarantineTemplate.$HexName" -FieldValue $Policy.StateIsCorrect -TenantFilter $Tenant
189190
}
190191
}
191192
}

0 commit comments

Comments
 (0)