@@ -13,6 +13,26 @@ function Invoke-ListStandardsCompare {
1313 $TenantFilter = $Request.Query.tenantFilter
1414 $TemplateFilter = $Request.Query.templateId
1515
16+ # Get-CIPPStandards is the authoritative source for what is currently in scope.
17+ $StandardParams = @ {}
18+ if ($TemplateFilter ) { $StandardParams.TemplateId = $TemplateFilter }
19+ if ($TenantFilter ) { $StandardParams.TenantFilter = $TenantFilter }
20+ $StandardList = Get-CIPPStandards @StandardParams
21+
22+ $ScopedTemplateGuids = [System.Collections.Generic.HashSet [string ]]::new([System.StringComparer ]::OrdinalIgnoreCase)
23+ $ScopedQuarantineNames = [System.Collections.Generic.HashSet [string ]]::new([System.StringComparer ]::OrdinalIgnoreCase)
24+ foreach ($Entry in $StandardList ) {
25+ switch ($Entry.Standard ) {
26+ { $_ -in @ (' IntuneTemplate' , ' ConditionalAccessTemplate' ) } {
27+ if ($Entry.Settings.TemplateList.value ) { $null = $ScopedTemplateGuids.Add ($Entry.Settings.TemplateList.value ) }
28+ }
29+ ' QuarantineTemplate' {
30+ $DisplayName = $Entry.Settings.displayName.value ?? $Entry.Settings.displayName
31+ if ($DisplayName ) { $null = $ScopedQuarantineNames.Add ($DisplayName ) }
32+ }
33+ }
34+ }
35+
1636 $Filters = [system.collections.generic.list [string ]]::new()
1737 if ($TenantFilter ) {
1838 $Filters.Add (" PartitionKey eq '{0}'" -f $TenantFilter )
@@ -34,6 +54,20 @@ function Invoke-ListStandardsCompare {
3454 $FieldValue = $Standard.Value
3555 $Tenant = $Standard.PartitionKey
3656
57+ # Skip rows for template types no longer in scope per the current standard list.
58+ if ($FieldName -match ' ^standards\.(IntuneTemplate|ConditionalAccessTemplate)\.(.+)$' ) {
59+ if (-not $ScopedTemplateGuids.Contains ($Matches [2 ])) { continue }
60+ } elseif ($ScopedQuarantineNames.Count -gt 0 -and $FieldName -match ' ^standards\.QuarantineTemplate\.(.+)$' ) {
61+ # Decode hex-encoded display name and check if it's still in scope
62+ $HexEncoded = $Matches [1 ]
63+ $Chars = [System.Collections.Generic.List [char ]]::new()
64+ for ($i = 0 ; $i -lt $HexEncoded.Length ; $i += 2 ) {
65+ $Chars.Add ([char ][Convert ]::ToInt32($HexEncoded.Substring ($i , 2 ), 16 ))
66+ }
67+ $DecodedName = -join $Chars
68+ if (-not $ScopedQuarantineNames.Contains ($DecodedName )) { continue }
69+ }
70+
3771 # decode field names that are hex encoded (e.g. QuarantineTemplates)
3872 if ($FieldName -match ' ^(standards\.QuarantineTemplate\.)(.+)$' ) {
3973 $Prefix = $Matches [1 ]
0 commit comments