Skip to content

Commit 4b58de2

Browse files
committed
Enhance standard info logging and rerun detection
Push-CIPPStandard.ps1 now builds a more detailed API key for rerun detection and sets a script-level StandardInfo object with template IDs for Intune and Conditional Access standards. Write-LogMessage.ps1 is updated to include these new StandardInfo fields in log entries, improving traceability and debugging.
1 parent 5169c66 commit 4b58de2

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Standards/Push-CIPPStandard.ps1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,32 @@ function Push-CIPPStandard {
1212
$Standard = $Item.Standard
1313
$FunctionName = 'Invoke-CIPPStandard{0}' -f $Standard
1414
Write-Information "We'll be running $FunctionName"
15-
$Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -API "$($Standard)_$($Item.templateId)"
15+
16+
if ($Standard -in @('IntuneTemplate', 'ConditionalAccessTemplate')) {
17+
$API = "$Standard_$($Item.templateId)_$($Item.Settings.TemplateList.value)"
18+
} else {
19+
$API = "$Standard_$($Item.templateId)"
20+
}
21+
22+
$Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -API $API
1623
if ($Rerun) {
1724
Write-Information 'Detected rerun. Exiting cleanly'
1825
exit 0
1926
} else {
2027
Write-Information "Rerun is set to false. We'll be running $FunctionName"
2128
}
29+
30+
$script:StandardInfo = @{
31+
Standard = $Standard
32+
StandardTemplateId = $Item.templateId
33+
}
34+
if ($Standard -eq 'IntuneTemplate') {
35+
$script:StandardInfo.IntuneTemplateId = $Item.Settings.TemplateList.value
36+
}
37+
if ($Standard -eq 'ConditionalAccessTemplate') {
38+
$script:StandardInfo.ConditionalAccessTemplateId = $Item.Settings.TemplateList.value
39+
}
40+
2241
try {
2342
# Convert settings to JSON, replace %variables%, then convert back to object
2443
$SettingsJSON = $Item.Settings | ConvertTo-Json -Depth 10 -Compress

Modules/CIPPCore/Public/GraphHelper/Write-LogMessage.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ function Write-LogMessage {
6666
if ($tenantId) {
6767
$TableRow.Add('TenantID', [string]$tenantId)
6868
}
69+
if ($script:StandardInfo) {
70+
$TableRow.Standard = [string]$script:StandardInfo.Standard
71+
$TableRow.StandardTemplateId = [string]$script:StandardInfo.StandardTemplateId
72+
if ($script:StandardInfo.IntuneTemplate) {
73+
$TableRow.IntuneTemplateId = [string]$script:StandardInfo.IntuneTemplateId
74+
}
75+
if ($script:StandardInfo.ConditionalAccessTemplate) {
76+
$TableRow.ConditionalAccessTemplateId = [string]$script:StandardInfo.ConditionalAccessTemplateId
77+
}
78+
}
6979

7080
$Table.Entity = $TableRow
7181
Add-CIPPAzDataTableEntity @Table | Out-Null

0 commit comments

Comments
 (0)