@@ -31,6 +31,72 @@ function Get-CIPPStandards {
3131 $_.GUID -like $TemplateId -and $_.runManually -eq $runManually
3232 }
3333
34+ # 1.5. Expand templates that contain TemplateList-Tags into multiple standards
35+ $ExpandedTemplates = foreach ($Template in $Templates ) {
36+ $NewTemplate = $Template.PSObject.Copy ()
37+ $ExpandedStandards = [ordered ]@ {}
38+ $HasExpansions = $false
39+
40+ foreach ($StandardName in $Template.standards.PSObject.Properties.Name ) {
41+ $StandardValue = $Template.standards .$StandardName
42+ $IsArray = $StandardValue -is [System.Collections.IEnumerable ] -and -not ($StandardValue -is [string ])
43+
44+ if ($IsArray ) {
45+ $NewArray = @ ()
46+ foreach ($Item in $StandardValue ) {
47+ if ($Item .' TemplateList-Tags' .value) {
48+ $HasExpansions = $true
49+ $Table = Get-CippTable - tablename ' templates'
50+ $Filter = " PartitionKey eq 'IntuneTemplate'"
51+ $TemplatesList = Get-CIPPAzDataTableEntity @Table - Filter $Filter | Where-Object - Property package -EQ $Item .' TemplateList-Tags' .value
52+
53+ foreach ($TemplateItem in $TemplatesList ) {
54+ $NewItem = $Item.PSObject.Copy ()
55+ $NewItem.PSObject.Properties.Remove (' TemplateList-Tags' )
56+ $NewItem | Add-Member - NotePropertyName TemplateList - NotePropertyValue ([pscustomobject ]@ {
57+ label = " $ ( $TemplateItem.RowKey ) "
58+ value = " $ ( $TemplateItem.RowKey ) "
59+ }) - Force
60+ $NewArray = $NewArray + $NewItem
61+ }
62+ } else {
63+ $NewArray = $NewArray + $Item
64+ }
65+ }
66+ $ExpandedStandards [$StandardName ] = $NewArray
67+ } else {
68+ if ($StandardValue .' TemplateList-Tags' .value) {
69+ $HasExpansions = $true
70+ $Table = Get-CippTable - tablename ' templates'
71+ $Filter = " PartitionKey eq 'IntuneTemplate'"
72+ $TemplatesList = Get-CIPPAzDataTableEntity @Table - Filter $Filter | Where-Object - Property package -EQ $StandardValue .' TemplateList-Tags' .value
73+
74+ $NewArray = @ ()
75+ foreach ($TemplateItem in $TemplatesList ) {
76+ $NewItem = $StandardValue.PSObject.Copy ()
77+ $NewItem.PSObject.Properties.Remove (' TemplateList-Tags' )
78+ $NewItem | Add-Member - NotePropertyName TemplateList - NotePropertyValue ([pscustomobject ]@ {
79+ label = " $ ( $TemplateItem.RowKey ) "
80+ value = " $ ( $TemplateItem.RowKey ) "
81+ }) - Force
82+ $NewArray = $NewArray + $NewItem
83+ }
84+ $ExpandedStandards [$StandardName ] = $NewArray
85+ } else {
86+ $ExpandedStandards [$StandardName ] = $StandardValue
87+ }
88+ }
89+ }
90+
91+ if ($HasExpansions ) {
92+ $NewTemplate.standards = [pscustomobject ]$ExpandedStandards
93+ }
94+
95+ $NewTemplate
96+ }
97+
98+ $Templates = $ExpandedTemplates
99+
34100 # 2. Get tenant list, filter if needed
35101 $AllTenantsList = Get-Tenants
36102 if ($TenantFilter -ne ' allTenants' ) {
0 commit comments