Skip to content

Commit 41cb7f9

Browse files
change how drift detection works
1 parent f30527b commit 41cb7f9

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Modules/CIPPCore/Public/Get-CIPPDrift.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Get-CIPPDrift {
3030
)
3131

3232
try {
33-
$AlignmentData = Get-CIPPTenantAlignment -TenantFilter $TenantFilter -TemplateId $TemplateId
33+
$AlignmentData = Get-CIPPTenantAlignment -TenantFilter $TenantFilter -TemplateId $TemplateId | Where-Object -Property standardType -EQ 'drift'
3434
if (-not $AlignmentData) {
3535
Write-Warning "No alignment data found for tenant $TenantFilter"
3636
return @()
@@ -58,7 +58,7 @@ function Get-CIPPDrift {
5858
# Process standards compliance deviations
5959
if ($Alignment.ComparisonDetails) {
6060
foreach ($ComparisonItem in $Alignment.ComparisonDetails) {
61-
if ($ComparisonItem.Compliant -eq $false -and $ComparisonItem.ComplianceStatus -eq 'Non-Compliant') {
61+
if ($ComparisonItem.Compliant -ne $true) {
6262
$Status = if ($ExistingDriftStates.ContainsKey($ComparisonItem.StandardName)) {
6363
$ExistingDriftStates[$ComparisonItem.StandardName]
6464
} else {
@@ -196,9 +196,9 @@ function Get-CIPPDrift {
196196

197197
$CacheEntity = @{
198198
PartitionKey = 'drift'
199-
RowKey = $TenantFilter
200-
IntuneJson = $IntuneJsonString
201-
CAJson = $CAJsonString
199+
RowKey = $TenantFilter
200+
IntuneJson = $IntuneJsonString
201+
CAJson = $CAJsonString
202202
}
203203
Add-CIPPAzDataTableEntity @CacheTable -Entity $CacheEntity -Force
204204
} catch {
@@ -285,7 +285,7 @@ function Get-CIPPDrift {
285285
$PolicyDeviation = [PSCustomObject]@{
286286
standardName = $PolicyKey
287287
standardDisplayName = "Intune - $TenantPolicyName"
288-
expectedValue = 'Not defined in template'
288+
expectedValue = 'This policy only exists in the tenant, not in the template.'
289289
receivedValue = ($TenantPolicy.Policy | ConvertTo-Json -Depth 10 -Compress)
290290
state = 'current'
291291
Status = $Status
@@ -315,7 +315,7 @@ function Get-CIPPDrift {
315315
$PolicyDeviation = [PSCustomObject]@{
316316
standardName = $PolicyKey
317317
standardDisplayName = "Conditional Access - $($TenantCAPolicy.displayName)"
318-
expectedValue = 'Not defined in template'
318+
expectedValue = 'This policy only exists in the tenant, not in the template.'
319319
receivedValue = ($TenantCAPolicy | ConvertTo-Json -Depth 10 -Compress)
320320
state = 'current'
321321
Status = $Status

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
3030
#>
3131
param($Tenant, $Settings)
3232
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'ConditionalAccess'
33-
$TestResult = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')
3433
$Table = Get-CippTable -tablename 'templates'
35-
34+
$TestResult = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')
3635
if ($TestResult -eq $false) {
36+
#writing to each item that the license is not present.
37+
$settings.TemplateList | ForEach-Object {
38+
Set-CIPPStandardsCompareField -FieldName "standards.ConditionalAccessTemplate.$($_.value)" -FieldValue 'This tenant does not have the required license for this standard.' -Tenant $Tenant
39+
}
3740
Write-Host "We're exiting as the correct license is not present for this standard."
3841
return $true
3942
} #we're done.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ function Invoke-CIPPStandardIntuneTemplate {
3535
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'intuneTemplate'
3636

3737
if ($TestResult -eq $false) {
38+
#writing to each item that the license is not present.
39+
$settings.TemplateList | ForEach-Object {
40+
Set-CIPPStandardsCompareField -FieldName "standards.IntuneTemplate.$($_.value)" -FieldValue 'This tenant does not have the required license for this standard.' -Tenant $Tenant
41+
}
3842
Write-Host "We're exiting as the correct license is not present for this standard."
3943
return $true
4044
} #we're done.

0 commit comments

Comments
 (0)