Fix OIB assignment safety - #40
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens operational safety around two areas in IntuneHydrationKit: (1) preventing WinGet detection bootstrap logs from contaminating success-stream output used as the resolved executable path, and (2) adding a guarded Settings Catalog assignment script for Windows OIB policies that enforces ownership/target boundaries and fails closed in unsafe cases. It also revs the module metadata and changelog to v1.3.1.
Changes:
- Added
scripts/Set-WindowsOIBSettingsCatalogAssignments.ps1plus Pester coverage to safely automate intended All Users/All Devices assignments for managed OIB Settings Catalog policies while refusing filtered or policy-set-owned targets. - Updated WinGet detection script generation to emit bootstrap logging via
Write-Verboseinstead of the success stream. - Bumped version/release notes and updated
CHANGELOG.mdfor 1.3.1.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/Scripts/Set-WindowsOIBSettingsCatalogAssignments.Tests.ps1 | New Pester tests covering OIB policy selection and guarded assignment behavior. |
| Tests/Private/Get-WinGetDetectionScriptContent.Tests.ps1 | Adds an assertion that bootstrap logging stays out of the success stream. |
| scripts/Set-WindowsOIBSettingsCatalogAssignments.ps1 | New guarded assignment automation for Windows OIB Settings Catalog policies. |
| scripts/AssignmentHelpers.ps1 | Extends graph connect helper to accept a required scope (but currently has a scope-variable bug). |
| Private/WinGet/Get-WinGetDetectionScriptContent.ps1 | Switches detection logging from Write-Output to Write-Verbose. |
| IntuneHydrationKit.psd1 | Version bump to 1.3.1 and updated release notes content. |
| CHANGELOG.md | Adds 1.3.1 entry describing the fixes. |
The fix in The bug: The fix: All three occurrences are consistently updated to Test coverage: The two new |
The fix in The bug: The policy-set ownership check ( The fix: The ownership check is now the first thing evaluated after fetching existing assignments. Any policy-set-owned assignment on the policy — regardless of target type — throws before any "safe" early return can be reached. Test coverage: The new |
The reviewer's finding was valid — Fixed in the latest commit: $status = if ($WhatIfPreference) { 'WhatIf' } else { 'Cancelled' }All 12 focused tests and 1,099 total tests pass. |
The cancellation-status regression coverage in The refactor: Test coverage: Both branches are exercised directly by the new |
|
Reviewed |
Summary
Root cause
WinGet detection emitted bootstrap logs through the success stream, and Settings Catalog assignment automation needed explicit ownership and target-scope boundaries before replaying assignments.
Validation
./build.ps1 -Task CI