Skip to content

Commit de99211

Browse files
new tags
1 parent cba5f92 commit de99211

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

Modules/CIPPCore/Public/Functions/Get-CIPPTenantAlignment.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ function Get-CIPPTenantAlignment {
158158
ReportingEnabled = $IntuneReportingEnabled
159159
}
160160
}
161+
if ($IntuneTemplate.'TemplateList-Tags') {
162+
foreach ($Tag in $IntuneTemplate.'TemplateList-Tags') {
163+
Write-Host "Processing Intune Tag: $($Tag.value)"
164+
$IntuneActions = if ($IntuneTemplate.action) { $IntuneTemplate.action } else { @() }
165+
$IntuneReportingEnabled = ($IntuneActions | Where-Object { $_.value -and ($_.value.ToLower() -eq 'report' -or $_.value.ToLower() -eq 'remediate') }).Count -gt 0
166+
$TemplatesList = Get-CIPPAzDataTableEntity @TemplateTable -Filter $Filter | Where-Object -Property package -EQ $Tag.value
167+
$TemplatesList | ForEach-Object {
168+
$TagStandardId = "standards.IntuneTemplate.$($_.GUID)"
169+
[PSCustomObject]@{
170+
StandardId = $TagStandardId
171+
ReportingEnabled = $IntuneReportingEnabled
172+
}
173+
}
174+
175+
}
176+
}
161177
}
162178
}
163179
# Handle Conditional Access templates specially
@@ -224,7 +240,7 @@ function Get-CIPPTenantAlignment {
224240
[PSCustomObject]@{
225241
StandardName = $StandardKey
226242
Compliant = $IsCompliant
227-
StandardValue = ($Value | ConvertTo-Json -Compress)
243+
StandardValue = ($Value | ConvertTo-Json -Depth 100 -Compress)
228244
ComplianceStatus = $ComplianceStatus
229245
ReportingDisabled = $IsReportingDisabled
230246
}

Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)