Skip to content

fix(windows): respect managed power button policy - #713

Merged
DevSecNinja merged 1 commit into
mainfrom
devsecninja-fix-surface-policy-conflict
Aug 14, 2026
Merged

fix(windows): respect managed power button policy#713
DevSecNinja merged 1 commit into
mainfrom
devsecninja-fix-surface-policy-conflict

Conversation

@DevSecNinja

Copy link
Copy Markdown
Owner

Summary

  • detect the documented ACSettingIndex and DCSettingIndex policy values before invoking powercfg
  • return ManagedByPolicy without writes when both values enforce Take no action
  • fail with actionable policy ownership details for partial or conflicting policy configuration
  • preserve unmanaged Surface behavior, non-Surface skips, WhatIf, PowerShell 5.1 native-error handling, and strict nonzero exit propagation
  • add focused Pester coverage for registry detection, desired and conflicting policy, idempotency, unmanaged writes, WhatIf, and native errors

Root cause

PR #711 added a current-user powercfg write for Surface Laptop power-button behavior. Machines provisioned by windows-iso-maker already carry machine-wide Power ADMX policy values for the same setting, so Windows correctly rejects the lower-precedence power-plan write with a Group Policy override error.

Validation

  • targeted Pester: 14 passed
  • full PowerShell Pester suite: 798 passed, 14 skipped
  • PSScriptAnalyzer: no Error/Warning findings
  • chezmoi apply --dry-run --source=.: passed
  • Lefthook pre-commit (shellcheck, shfmt, executable-bit checks): passed
  • Bash/Bats broader suite: 855 passed and 1 unrelated existing git-config-credentials failure on this environment

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@DevSecNinja
DevSecNinja merged commit 9b419b0 into main Aug 14, 2026
16 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-fix-surface-policy-conflict branch August 14, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant