Skip to content

Commit 1777132

Browse files
change in tag processing
1 parent 464ff61 commit 1777132

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Get-CIPPTenantAlignment {
2929
try {
3030
# Get all standard templates
3131
$Templates = (Get-CIPPAzDataTableEntity @TemplateTable -Filter $TemplateFilter) | ForEach-Object {
32-
$JSON = $_.JSON -replace '"Action":', '"action":'
32+
$JSON = $_.JSON
3333
try {
3434
$RowKey = $_.RowKey
3535
$Data = $JSON | ConvertFrom-Json -Depth 100 -ErrorAction Stop
@@ -65,7 +65,7 @@ function Get-CIPPTenantAlignment {
6565
$Tenants = Get-Tenants -IncludeErrors
6666
$AllStandards | Where-Object { $_.PartitionKey -in $Tenants.defaultDomainName }
6767
}
68-
68+
$TagTemplates = Get-CIPPAzDataTableEntity @TemplateTable
6969
# Build tenant standards data structure
7070
$tenantData = @{}
7171
foreach ($Standard in $Standards) {
@@ -76,18 +76,12 @@ function Get-CIPPTenantAlignment {
7676
# Process field value
7777
if ($FieldValue -is [System.Boolean]) {
7878
$FieldValue = [bool]$FieldValue
79-
} elseif (Test-Json -Json $FieldValue -ErrorAction SilentlyContinue) {
79+
} else {
8080
try {
81-
$FieldValue = ConvertFrom-Json -Depth 100 -InputObject $FieldValue -ErrorAction Stop
81+
$FieldValue = ConvertFrom-Json -Depth 5 -InputObject $FieldValue -ErrorAction Stop
8282
} catch {
83-
Write-Warning "$($FieldName) standard report could not be loaded: $($_.Exception.Message)"
84-
$FieldValue = [PSCustomObject]@{
85-
Error = "Invalid JSON format: $($_.Exception.Message)"
86-
OriginalValue = $FieldValue
87-
}
83+
$FieldValue = [string]$FieldValue
8884
}
89-
} else {
90-
$FieldValue = [string]$FieldValue
9185
}
9286

9387
if (-not $tenantData.ContainsKey($Tenant)) {
@@ -181,6 +175,7 @@ function Get-CIPPTenantAlignment {
181175
ReportingEnabled = $IntuneReportingEnabled
182176
}
183177
}
178+
184179
if ($IntuneTemplate.'TemplateList-Tags') {
185180
foreach ($Tag in $IntuneTemplate.'TemplateList-Tags') {
186181
Measure-CippTask -TaskName 'Template.ProcessIntuneTag' -EventName 'CIPP.TenantAlignment.Profile' -Metadata @{
@@ -189,8 +184,8 @@ function Get-CIPPTenantAlignment {
189184
Write-Host "Processing Intune Tag: $($Tag.value)"
190185
$IntuneActions = if ($IntuneTemplate.action) { $IntuneTemplate.action } else { @() }
191186
$IntuneReportingEnabled = ($IntuneActions | Where-Object { $_.value -and ($_.value.ToLower() -eq 'report' -or $_.value.ToLower() -eq 'remediate') }).Count -gt 0
192-
$TemplatesList = Get-CIPPAzDataTableEntity @TemplateTable -Filter $Filter | Where-Object -Property package -EQ $Tag.value
193-
$TemplatesList | ForEach-Object {
187+
$TagTemplates | Where-Object -Property package -EQ $Tag.value
188+
$TagTemplates | ForEach-Object {
194189
$TagStandardId = "standards.IntuneTemplate.$($_.GUID)"
195190
[PSCustomObject]@{
196191
StandardId = $TagStandardId

0 commit comments

Comments
 (0)