Add Group Policy template adapter - #1686
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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_templatecrate 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.
…icy-template-adapter
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
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>
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>
😊 Code Coverage ReportChanged Code Coverage87% (80%+ coverage)
🔵 Full Codebase Coverage82% (good)
|
Cover ADMX and ADML parsing, generated schemas, value conversion, validation paths, encoding handling, and isolated current-user registry round trips. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Treat absent or blank get input as an empty object so adapted resources return all current values using the default current-user scope. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Verify a configured current-user policy is returned by the adapted resource get command when no input is supplied. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Normalize policy names, expose Enabled, Disabled, and NotConfigured states, and always return a state for every adapted policy property. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Enumerate registry values for ADMX list elements during no-input get operations and cover the PowerShell module logging scenario. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Generate array schemas for ADMX list elements and map their registry values to stable string lists for get and set operations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Hi yes I thinking about those settings [Unicode]
Unicode=yes
[System Access]
MinimumPasswordAge = 0
MaximumPasswordAge = 42
MinimumPasswordLength = 0
PasswordComplexity = 0
PasswordHistorySize = 0
LockoutBadCount = 10
ResetLockoutCount = 10
LockoutDuration = 10
AllowAdministratorLockout = 1
RequireLogonToChangePassword = 0
ForceLogoffWhenHourExpire = 0
NewAdministratorName = "Administrator"
NewGuestName = "Guest"
ClearTextPassword = 0
LSAAnonymousNameLookup = 0
EnableAdminAccount = 0
EnableGuestAccount = 0
[Event Audit]
AuditSystemEvents = 0
AuditLogonEvents = 0
AuditObjectAccess = 0
AuditPrivilegeUse = 0
AuditPolicyChange = 0
AuditAccountManage = 0
AuditProcessTracking = 0
AuditDSAccess = 0
AuditAccountLogon = 0
[Registry Values]
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\SecurityLevel=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\SetCommand=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\CachedLogonsCount=1,"10"
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ForceUnlockLogon=4,0
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\PasswordExpiryWarning=4,5
MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ScRemoveOption=1,"0"
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin=4,5
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorEnhancedAdmin=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorUser=4,3
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLastUserName=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableInstallerDetection=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableSecureUIAPaths=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableUIADesktopToggle=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableVirtualization=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\LegalNoticeCaption=1,""
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\LegalNoticeText=7,
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\PromptOnSecureDesktop=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ScForceOption=4,0
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ShutdownWithoutLogon=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\TypeOfAdminApprovalMode=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\UndockWithoutLogon=4,1
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ValidateAdminCodeSignatures=4,0
MACHINE\Software\Policies\Microsoft\Windows\Safer\CodeIdentifiers\AuthenticodeEnabled=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\AuditBaseObjects=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\CrashOnAuditFail=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\DisableDomainCreds=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\EveryoneIncludesAnonymous=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\ForceGuest=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\FullPrivilegeAuditing=3,0
MACHINE\System\CurrentControlSet\Control\Lsa\LimitBlankPasswordUse=4,1
MACHINE\System\CurrentControlSet\Control\Lsa\MSV1_0\NTLMMinClientSec=4,536870912
MACHINE\System\CurrentControlSet\Control\Lsa\MSV1_0\NTLMMinServerSec=4,536870912
MACHINE\System\CurrentControlSet\Control\Lsa\NoLMHash=4,1
MACHINE\System\CurrentControlSet\Control\Lsa\RestrictAnonymous=4,0
MACHINE\System\CurrentControlSet\Control\Lsa\RestrictAnonymousSAM=4,1
MACHINE\System\CurrentControlSet\Control\Print\Providers\LanMan Print Services\Servers\AddPrinterDrivers=4,0
MACHINE\System\CurrentControlSet\Control\SecurePipeServers\Winreg\AllowedExactPaths\Machine=7,System\CurrentControlSet\Control\ProductOptions,System\CurrentControlSet\Control\Server Applications,Software\Microsoft\Windows NT\CurrentVersion
MACHINE\System\CurrentControlSet\Control\SecurePipeServers\Winreg\AllowedPaths\Machine=7,System\CurrentControlSet\Control\Print\Printers,System\CurrentControlSet\Services\Eventlog,Software\Microsoft\OLAP Server,Software\Microsoft\Windows NT\CurrentVersion\Print,Software\Microsoft\Windows NT\CurrentVersion\Windows,System\CurrentControlSet\Control\ContentIndex,System\CurrentControlSet\Control\Terminal Server,System\CurrentControlSet\Control\Terminal Server\UserConfig,System\CurrentControlSet\Control\Terminal Server\DefaultUserConfiguration,Software\Microsoft\Windows NT\CurrentVersion\Perflib,System\CurrentControlSet\Services\SysmonLog
MACHINE\System\CurrentControlSet\Control\Session Manager\Kernel\ObCaseInsensitive=4,1
MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management\ClearPageFileAtShutdown=4,0
MACHINE\System\CurrentControlSet\Control\Session Manager\ProtectionMode=4,1
MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\optional=7,
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\AutoDisconnect=4,15
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\EnableForcedLogOff=4,1
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\EnableSecuritySignature=4,0
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes=7,
MACHINE\System\CurrentControlSet\Services\LanManServer\Parameters\RestrictNullSessAccess=4,1
MACHINE\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\EnablePlainTextPassword=4,0
MACHINE\System\CurrentControlSet\Services\LanmanWorkstation\Parameters\EnableSecuritySignature=4,1
MACHINE\System\CurrentControlSet\Services\LDAP\LDAPClientConfidentiality=4,1
MACHINE\System\CurrentControlSet\Services\LDAP\LDAPClientIntegrity=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange=4,0
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\MaximumPasswordAge=4,30
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\RequireSignOrSeal=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\RequireStrongKey=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\SealSecureChannel=4,1
MACHINE\System\CurrentControlSet\Services\Netlogon\Parameters\SignSecureChannel=4,1
[Privilege Rights]
SeNetworkLogonRight = *S-1-1-0,*S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551
SeBackupPrivilege = *S-1-5-32-544,*S-1-5-32-551
SeChangeNotifyPrivilege = *S-1-1-0,*S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551,*S-1-5-99-216390572-1995538116-3857911515-2404958512-2623887229
SeSystemtimePrivilege = *S-1-5-19,*S-1-5-32-544
SeCreatePagefilePrivilege = *S-1-5-32-544
SeDebugPrivilege = *S-1-5-32-544
SeRemoteShutdownPrivilege = *S-1-5-32-544
SeAuditPrivilege = *S-1-5-19,*S-1-5-20,*S-1-5-99-216390572-1995538116-3857911515-2404958512-2623887229
SeIncreaseQuotaPrivilege = *S-1-5-19,*S-1-5-20,*S-1-5-32-544
SeIncreaseBasePriorityPrivilege = *S-1-5-32-544,*S-1-5-90-0
SeLoadDriverPrivilege = *S-1-5-32-544
SeBatchLogonRight = *S-1-5-32-544,*S-1-5-32-551,*S-1-5-32-559
SeServiceLogonRight = *S-1-5-80-0,*S-1-5-83-0,*S-1-5-99-0
SeInteractiveLogonRight = Guest,*S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551
SeSecurityPrivilege = *S-1-5-32-544
SeSystemEnvironmentPrivilege = *S-1-5-32-544
SeProfileSingleProcessPrivilege = *S-1-5-32-544
SeSystemProfilePrivilege = *S-1-5-32-544,*S-1-5-80-3139157870-2983391045-3678747466-658725712-1809340420
SeAssignPrimaryTokenPrivilege = *S-1-5-19,*S-1-5-20
SeRestorePrivilege = *S-1-5-32-544,*S-1-5-32-551
SeShutdownPrivilege = *S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551
SeTakeOwnershipPrivilege = *S-1-5-32-544
SeDenyNetworkLogonRight = Guest
SeDenyInteractiveLogonRight = Guest
SeUndockPrivilege = *S-1-5-32-544,*S-1-5-32-545
SeManageVolumePrivilege = *S-1-5-32-544
SeRemoteInteractiveLogonRight = *S-1-5-32-544,*S-1-5-32-555
SeImpersonatePrivilege = *S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-6,*S-1-5-99-216390572-1995538116-3857911515-2404958512-2623887229
SeCreateGlobalPrivilege = *S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-6
SeIncreaseWorkingSetPrivilege = *S-1-5-32-545
SeTimeZonePrivilege = *S-1-5-19,*S-1-5-32-544,*S-1-5-32-545
SeCreateSymbolicLinkPrivilege = *S-1-5-32-544,*S-1-5-83-0
SeDelegateSessionUserImpersonatePrivilege = *S-1-5-32-544
[Version]
signature="$CHICAGO$"
Revision=1
I created this resource and I thinki this will be supported by native resource or I can still develop this project: https://github.com/mimachniak/ADSGroupPolicyDSCv3 |
|
Michal Machniak (@mimachniak) as I noted, this adapter is specifically for ADMX files, not GPO generally. If you're primarily building a resource around registry keys/values, you should take a look at the new capability I added to the registry adapter. Here's an example resource mapped to the registry which only requires a resource manifest to describe the mapping and no code at all. |
thx for information |
Expose ADMX policies without child settings as enabled, disabled, or notConfigured while preserving the existing nested policy state contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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/GroupPolicyTemplateadapter. It scans%SystemRoot%\PolicyDefinitions, resolves localized ADML strings, groups policies into adaptedGPO.<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