Skip to content

Add Group Policy template adapter - #1686

Open
Steve Lee (SteveL-MSFT) wants to merge 7 commits into
mainfrom
stevel-msft-group-policy-template-adapter
Open

Add Group Policy template adapter#1686
Steve Lee (SteveL-MSFT) wants to merge 7 commits into
mainfrom
stevel-msft-group-policy-template-adapter

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Aug 21, 2026

Copy link
Copy Markdown
Member

Windows Group Policy templates vary by machine, so DSC needs a dynamic adapter that discovers the locally installed ADMX definitions and exposes them as manageable resources.

This adds the Rust-based Microsoft.Adapter/GroupPolicyTemplate adapter. It scans %SystemRoot%\PolicyDefinitions, resolves localized ADML strings, groups policies into adapted GPO.<parentCategory>/<category> resources, and generates JSON Schema for policy toggles and ADMX child elements. Get and set operations map user and machine scope to HKCU and HKLM while preserving ADMX registry value types, delete semantics, policy class restrictions, and enabled/disabled value lists.

Pester coverage verifies adapter discovery against installed ADMX files and includes an elevated, current-user-only mutation test with state restoration. Rust unit tests cover naming, binary parsing, and scope-to-hive mapping.

Fix #575

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Rust-based DSC adapter (Microsoft.Adapter/GroupPolicyTemplate) that discovers locally installed Windows Group Policy ADMX/ADML templates and exposes them as dynamically generated DSC resources, with get/set backed by registry operations.

Changes:

  • Adds a new adapters/group_policy_template crate implementing ADMX parsing, schema generation, and registry-backed get/set.
  • Registers the adapter in the workspace (members/default-members/Windows set) and adds required dependencies (roxmltree, Windows globalization feature).
  • Adds Pester + Rust unit tests to validate discovery and a basic current-user mutation scenario.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Cargo.toml Adds the new adapter crate to workspace membership and adds dependencies/features needed for XML + locale support.
Cargo.lock Locks the new adapter crate and roxmltree dependency.
adapters/group_policy_template/Cargo.toml Defines the new adapter crate and its dependencies/targets.
adapters/group_policy_template/src/main.rs Implements adapter CLI dispatch (list/get/set), stdout output, and structured JSON error reporting.
adapters/group_policy_template/src/admx.rs Implements ADMX/ADML discovery, locale resolution, resource modeling, and JSON Schema generation.
adapters/group_policy_template/src/registry.rs Implements policy state read/write logic by mapping scope to HKCU/HKLM and applying registry value semantics.
adapters/group_policy_template/locales/en-us.toml Adds i18n strings for user-facing adapter messages.
adapters/group_policy_template/group_policy_template.dsc.resource.json Adds the DSC adapter manifest wiring list/get/set to the new executable.
adapters/group_policy_template/tests/group_policy_template.tests.ps1 Adds Pester coverage for discovery and an elevated current-user mutation test with restoration.
adapters/group_policy_template/.project.data.json Registers the adapter in repo metadata/build packaging (binary + copy files).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread adapters/group_policy_template/src/registry.rs
Comment thread adapters/group_policy_template/src/admx.rs
Comment thread adapters/group_policy_template/tests/group_policy_template.tests.ps1 Outdated
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) and others added 2 commits August 22, 2026 07:01
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mimachniak

Copy link
Copy Markdown
Contributor

This will also support security settings ? And GPO version change ?

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

This will also support security settings ? And GPO version change ?

Can you be more specific on what you're asking for? (I'm not a GPO expert). This adapter is only targeting admx templates.

Update UTF-16 decoding for the newer Clippy lint and keep localization keys aligned with their uses.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Comment thread adapters/group_policy_template/src/admx.rs Outdated
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) and others added 3 commits August 22, 2026 09:16
Use stable ADMX category identifiers for adapted resource type names and explicitly select the adapter in mutation tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the unsupported adapter selector from resource get and set test invocations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Prime the lookup table with all Microsoft adapters so repeat discovery does not add Group Policy resources unexpectedly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Adapter for admx templates

3 participants