Skip to content

Commit 470c024

Browse files
updates to compares and prettification
1 parent 6ad08e8 commit 470c024

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListStandardsCompare.ps1

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,29 @@ function Invoke-ListStandardsCompare {
5353
$FieldValue = [string]$FieldValue
5454
}
5555

56+
# Parse CurrentValue and ExpectedValue from JSON if they are JSON strings
57+
$ParsedCurrentValue = if ($Standard.CurrentValue -and (Test-Json -Json $Standard.CurrentValue -ErrorAction SilentlyContinue)) {
58+
ConvertFrom-Json -InputObject $Standard.CurrentValue -ErrorAction SilentlyContinue
59+
} else {
60+
$Standard.CurrentValue
61+
}
62+
63+
$ParsedExpectedValue = if ($Standard.ExpectedValue -and (Test-Json -Json $Standard.ExpectedValue -ErrorAction SilentlyContinue)) {
64+
ConvertFrom-Json -InputObject $Standard.ExpectedValue -ErrorAction SilentlyContinue
65+
} else {
66+
$Standard.ExpectedValue
67+
}
68+
5669
if (-not $TenantStandards.ContainsKey($Tenant)) {
5770
$TenantStandards[$Tenant] = @{}
5871
}
5972
$TenantStandards[$Tenant][$FieldName] = @{
60-
Value = $FieldValue
61-
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
62-
TemplateId = $Standard.TemplateId
73+
Value = $FieldValue
74+
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
75+
TemplateId = $Standard.TemplateId
76+
LicenseAvailable = $Standard.LicenseAvailable
77+
CurrentValue = $ParsedCurrentValue
78+
ExpectedValue = $ParsedExpectedValue
6379
}
6480
}
6581

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ function Get-CIPPTenantAlignment {
9090
$tenantData[$Tenant] = @{}
9191
}
9292
$tenantData[$Tenant][$FieldName] = @{
93-
Value = $FieldValue
94-
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
93+
Value = $FieldValue
94+
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
95+
LicenseAvailable = $Standard.LicenseAvailable
96+
CurrentValue = $Standard.CurrentValue
97+
ExpectedValue = $Standard.ExpectedValue
9598
}
9699
}
97100
$TenantStandards = $tenantData
@@ -276,6 +279,9 @@ function Get-CIPPTenantAlignment {
276279
StandardValue = $StandardValueJson
277280
ComplianceStatus = $ComplianceStatus
278281
ReportingDisabled = $IsReportingDisabled
282+
LicenseAvailable = $StandardObject.LicenseAvailable
283+
CurrentValue = $StandardObject.CurrentValue
284+
ExpectedValue = $StandardObject.ExpectedValue
279285
})
280286
} else {
281287
$ComplianceStatus = if ($IsReportingDisabled) {
@@ -290,6 +296,9 @@ function Get-CIPPTenantAlignment {
290296
StandardValue = 'NOT FOUND'
291297
ComplianceStatus = $ComplianceStatus
292298
ReportingDisabled = $IsReportingDisabled
299+
LicenseAvailable = $null
300+
CurrentValue = $null
301+
ExpectedValue = $null
293302
})
294303
}
295304
}

Modules/CIPPCore/Public/Get-CIPPDrift.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ function Get-CIPPDrift {
129129
standardName = $ComparisonItem.StandardName
130130
standardDisplayName = $displayName
131131
standardDescription = $standardDescription
132-
expectedValue = 'Compliant'
133132
receivedValue = $ComparisonItem.StandardValue
134133
state = 'current'
135134
Status = $Status
136135
Reason = $reason
137136
lastChangedByUser = $User
137+
LicenseAvailable = $ComparisonItem.LicenseAvailable
138+
CurrentValue = $ComparisonItem.CurrentValue
139+
ExpectedValue = $ComparisonItem.ExpectedValue
138140
})
139141
}
140142
}
@@ -286,7 +288,7 @@ function Get-CIPPDrift {
286288
standardName = $PolicyKey
287289
standardDisplayName = "Intune - $TenantPolicyName"
288290
expectedValue = 'This policy only exists in the tenant, not in the template.'
289-
receivedValue = $TenantPolicy.Policy
291+
receivedValue = ($TenantPolicy.Policy | ConvertTo-Json -Depth 10 -Compress)
290292
state = 'current'
291293
Status = $Status
292294
Reason = $reason

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardEXODirectSend.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function Invoke-CIPPStandardEXODirectSend {
3838
# Input validation
3939
if ([string]::IsNullOrWhiteSpace($DesiredStateName) -or $DesiredStateName -eq 'Select a value') {
4040
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'EXODirectSend: Invalid state parameter set' -sev Error
41-
Return
41+
return
4242
}
4343

4444
# Get current organization config
@@ -85,8 +85,13 @@ function Invoke-CIPPStandardEXODirectSend {
8585

8686
# Report if needed
8787
if ($Settings.report -eq $true) {
88-
89-
Set-CIPPStandardsCompareField -FieldName 'standards.EXODirectSend' -FieldValue $StateIsCorrect -Tenant $Tenant
88+
$ExpectedState = @{
89+
RejectDirectSend = $DesiredState
90+
} | ConvertTo-Json -Depth 10 -Compress
91+
$CurrentState = @{
92+
RejectDirectSend = $CurrentConfig
93+
} | ConvertTo-Json -Depth 10 -Compress
94+
Set-CIPPStandardsCompareField -FieldName 'standards.EXODirectSend' -CurrentValue $CurrentState -ExpectedValue $ExpectedState -Tenant $Tenant
9095
Add-CIPPBPAField -FieldName 'EXODirectSend' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant
9196
}
9297
}

0 commit comments

Comments
 (0)