Commit 18d28ec
authored
Fix: Intune bundle drift remediation (KelvinTegelaar#1982)
# Summary
Fixes DeniedRemediate one-off drift remediation silently doing nothing
for IntuneTemplate policies added via tag bundles (TemplateList-Tags).
The scheduled task would complete "successfully" but the policy was
never deployed to Intune.
# Description
`Invoke-ExecUpdateDriftDeviation` resolves the template settings for a
DeniedRemediate one-off by filtering `standardSettings.IntuneTemplate`
on `TemplateList.value`. For templates added individually this works,
but for templates added via a tag bundle (e.g. "Core Policies (4
Templates)"), `TemplateList` is null and the templates live under
`TemplateList Tags.rawData.templates` instead. The `Where-Object`
returns nothing, `$Settings` ends up null, and the scheduled task calls
`Invoke-CIPPStandardIntuneTemplate` with no settings. The function then
wildcard-matches every template in the table and processes them as a
single blob, which doesn't match anything in Graph.
The fix adds a fallback that searches
`TemplateList-Tags.rawData.templates` for the template GUID when the
`TemplateList.value` lookup returns nothing. When found, it expands the
bundle entry into a proper `TemplateList` with the individual GUID,
matching the pattern `Get-CIPPStandards` already uses for bundle
expansion during normal standards runs. Also added a warning log when
neither path finds the template.
# Testing
1. Create a drift template with a **tag bundle** containing multiple
Intune templates (e.g. "Core Policies" with Config Refresh, LAPS, etc.)
2. Assign to a test tenant and run drift. Bundled policies should show
as deviations if they don't exist in the tenant
3. Mark a bundled template deviation as "Denied" (DeniedRemediate)
4. Wait for the one-off scheduled task to complete (or force it to /w
timer run)
5. Verify the policy is actually deployed in Intune (this is the bug
fix, previously it silently did nothing)
6. Verify the policy has the correct assignments from the bundle entry
7. Also test an **individual** (non-bundled) template DeniedRemediate to
confirm no regression on the original code path1 file changed
Lines changed: 23 additions & 5 deletions
File tree
- Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards
Lines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
53 | 71 | | |
54 | 72 | | |
55 | 73 | | |
| |||
91 | 109 | | |
92 | 110 | | |
93 | 111 | | |
94 | | - | |
| 112 | + | |
95 | 113 | | |
96 | 114 | | |
97 | 115 | | |
| |||
0 commit comments