@@ -26,15 +26,21 @@ function Get-CIPPStandards {
2626 # can compute correct precedence. The $TemplateId filter is applied after merge so that
2727 # manual runs of a single template don't bypass tenant-specific overrides.
2828 $Templates = (Get-CIPPAzDataTableEntity @Table - Filter $Filter | Sort-Object TimeStamp).JSON |
29- ForEach-Object {
30- try {
31- # Fix old "Action" => "action"
32- $JSON = $_ -replace ' "Action":' , ' "action":' -replace ' "permissionlevel":' , ' "permissionLevel":'
33- ConvertFrom-Json - InputObject $JSON - ErrorAction SilentlyContinue
34- } catch {}
35- } |
36- Where-Object {
37- $_.runManually -eq $runManually
29+ ForEach-Object {
30+ try {
31+ # Fix old "Action" => "action"
32+ $JSON = $_ -replace ' "Action":' , ' "action":' -replace ' "permissionlevel":' , ' "permissionLevel":'
33+ ConvertFrom-Json - InputObject $JSON - ErrorAction SilentlyContinue
34+ } catch {}
35+ } |
36+ Where-Object {
37+ $_.runManually -eq $runManually
38+ }
39+
40+ if ($TemplateId -ne ' *' -and ! [string ]::IsNullOrEmpty($TemplateId )) {
41+ $Templates = $Templates | Where-Object {
42+ $_.GUID -like $TemplateId
43+ }
3844 }
3945
4046 # 1.5. Expand templates that contain TemplateList-Tags into multiple standards
@@ -50,35 +56,35 @@ function Get-CIPPStandards {
5056
5157 if ($IsArray ) {
5258 $NewArray = @ (foreach ($Item in $StandardValue ) {
53- if ($Item .' TemplateList-Tags' .value) {
54- $HasExpansions = $true
55- $Table = Get-CippTable - tablename ' templates'
56- $PartitionKey = switch ($StandardName ) {
57- ' ConditionalAccessTemplate' { ' CATemplate' }
58- ' IntuneTemplate' { ' IntuneTemplate' }
59- default { ' IntuneTemplate' }
60- }
61- $Filter = " PartitionKey eq '$PartitionKey '"
62- $TemplatesList = Get-CIPPAzDataTableEntity @Table - Filter $Filter | Where-Object - Property package -EQ $Item .' TemplateList-Tags' .value
63- Write-Information " Expanding $StandardName tag '$ ( $Item .' TemplateList-Tags' .value) ' from partition '$PartitionKey ': found $ ( @ ($TemplatesList ).Count) templates"
64-
65- foreach ($TemplateItem in $TemplatesList ) {
66- $TemplateJSON = $TemplateItem.JSON | ConvertFrom-Json - Depth 100 - ErrorAction SilentlyContinue
67- $TemplateLabel = if ($TemplateJSON.displayName ) { $TemplateJSON.displayName } else { " $ ( $TemplateItem.RowKey ) " }
68- $NewItem = $Item.PSObject.Copy ()
69- $NewItem.PSObject.Properties.Remove (' TemplateList-Tags' )
70- $NewItem | Add-Member - NotePropertyName TemplateList - NotePropertyValue ([pscustomobject ]@ {
71- label = $TemplateLabel
72- value = " $ ( $TemplateItem.RowKey ) "
73- }) - Force
74- $NewItem | Add-Member - NotePropertyName TemplateId - NotePropertyValue $Template.GUID - Force
75- $NewItem
59+ if ($Item .' TemplateList-Tags' .value) {
60+ $HasExpansions = $true
61+ $Table = Get-CippTable - tablename ' templates'
62+ $PartitionKey = switch ($StandardName ) {
63+ ' ConditionalAccessTemplate' { ' CATemplate' }
64+ ' IntuneTemplate' { ' IntuneTemplate' }
65+ default { ' IntuneTemplate' }
66+ }
67+ $Filter = " PartitionKey eq '$PartitionKey '"
68+ $TemplatesList = Get-CIPPAzDataTableEntity @Table - Filter $Filter | Where-Object - Property package -EQ $Item .' TemplateList-Tags' .value
69+ Write-Information " Expanding $StandardName tag '$ ( $Item .' TemplateList-Tags' .value) ' from partition '$PartitionKey ': found $ ( @ ($TemplatesList ).Count) templates"
70+
71+ foreach ($TemplateItem in $TemplatesList ) {
72+ $TemplateJSON = $TemplateItem.JSON | ConvertFrom-Json - Depth 100 - ErrorAction SilentlyContinue
73+ $TemplateLabel = if ($TemplateJSON.displayName ) { $TemplateJSON.displayName } else { " $ ( $TemplateItem.RowKey ) " }
74+ $NewItem = $Item.PSObject.Copy ()
75+ $NewItem.PSObject.Properties.Remove (' TemplateList-Tags' )
76+ $NewItem | Add-Member - NotePropertyName TemplateList - NotePropertyValue ([pscustomobject ]@ {
77+ label = $TemplateLabel
78+ value = " $ ( $TemplateItem.RowKey ) "
79+ }) - Force
80+ $NewItem | Add-Member - NotePropertyName TemplateId - NotePropertyValue $Template.GUID - Force
81+ $NewItem
82+ }
83+ } else {
84+ $Item | Add-Member - NotePropertyName TemplateId - NotePropertyValue $Template.GUID - Force
85+ $Item
7686 }
77- } else {
78- $Item | Add-Member - NotePropertyName TemplateId - NotePropertyValue $Template.GUID - Force
79- $Item
80- }
81- })
87+ })
8288 if ($NewArray.Count -gt 0 ) {
8389 $ExpandedStandards [$StandardName ] = $NewArray
8490 }
0 commit comments