@@ -47,6 +47,19 @@ function Get-CIPPDrift {
4747 }
4848 } | Sort-Object - Property displayName
4949
50+ # Load all CA templates
51+ $CAFilter = " PartitionKey eq 'CATemplate'"
52+ $RawCATemplates = (Get-CIPPAzDataTableEntity @IntuneTable - Filter $CAFilter )
53+ $AllCATemplates = $RawCATemplates | ForEach-Object {
54+ try {
55+ $data = $_.JSON | ConvertFrom-Json - Depth 100 - ErrorAction SilentlyContinue
56+ $data | Add-Member - NotePropertyName ' GUID' - NotePropertyValue $_.RowKey - Force
57+ $data
58+ } catch {
59+ # Skip invalid templates
60+ }
61+ } | Sort-Object - Property displayName
62+
5063 try {
5164 $AlignmentData = Get-CIPPTenantAlignment - TenantFilter $TenantFilter - TemplateId $TemplateId | Where-Object - Property standardType -EQ ' drift'
5265 if (-not $AlignmentData ) {
@@ -95,6 +108,16 @@ function Get-CIPPDrift {
95108 $standardDescription = $Template.description
96109 }
97110 }
111+ # Handle Conditional Access templates
112+ if ($ComparisonItem.StandardName -like ' *ConditionalAccessTemplate*' ) {
113+ $CompareGuid = $ComparisonItem.StandardName.Split (' .' ) | Select-Object - Index 2
114+ Write-Host " Extracted CA GUID: $CompareGuid "
115+ $Template = $AllCATemplates | Where-Object { $_.GUID -like " *$CompareGuid *" }
116+ if ($Template ) {
117+ $displayName = $Template.displayName
118+ $standardDescription = $Template.description
119+ }
120+ }
98121 $reason = if ($ExistingDriftStates.ContainsKey ($ComparisonItem.StandardName )) { $ExistingDriftStates [$ComparisonItem.StandardName ].Reason }
99122 $User = if ($ExistingDriftStates.ContainsKey ($ComparisonItem.StandardName )) { $ExistingDriftStates [$ComparisonItem.StandardName ].User }
100123 $StandardsDeviations.Add ([PSCustomObject ]@ {
@@ -210,14 +233,6 @@ function Get-CIPPDrift {
210233 # Get actual CA templates from templates table
211234 if ($CATemplateIds.Count -gt 0 ) {
212235 try {
213- $CATable = Get-CippTable - tablename ' templates'
214- $CAFilter = " PartitionKey eq 'CATemplate'"
215- $AllCATemplates = (Get-CIPPAzDataTableEntity @CATable - Filter $CAFilter ) | ForEach-Object {
216- $data = $_.JSON | ConvertFrom-Json - Depth 100
217- $data | Add-Member - NotePropertyName ' GUID' - NotePropertyValue $_.GUID - Force
218- $data
219- } | Sort-Object - Property displayName
220-
221236 $TemplateCATemplates = $AllCATemplates | Where-Object { $_.GUID -in $CATemplateIds }
222237 } catch {
223238 Write-Warning " Failed to get CA templates: $ ( $_.Exception.Message ) "
0 commit comments