cheat-sheets

Group Policy

Group Policy applies settings to domain users and computers from Group Policy Objects (GPOs) linked to sites, domains and OUs. This sheet covers refreshing and reporting on policy, the GroupPolicy PowerShell module, the ADMX central store and troubleshooting. See Active Directory for the directory itself, Windows Networking for DNS and connectivity problems that break policy, and Windows Updates for update policy.

Documentation: Group Policy overview, GroupPolicy module

How Policy Applies #

  • Order (LSDOU): Local, Site, Domain, OU (nested OUs applied parent to child). The last applied wins on conflict.
  • Computer settings apply at startup, user settings at logon, then both refresh in the background (default every 90 minutes with a random 0 to 30 minute offset; domain controllers every 5 minutes).
  • Enforced links cannot be overridden by lower levels. Block Inheritance on an OU stops non-enforced GPOs from above.
  • Security filtering (Authenticated Users by default) decides who the GPO applies to. The account must also have Read permission, so keep Read for Authenticated Users or Domain Computers when you narrow the apply list.
  • WMI filters limit a GPO by a WMI query (for example an OS version).
  • Loopback processing applies the computer’s user settings regardless of who logs on (kiosks, RDS hosts).

Refresh and Report #

COMMANDDESCRIPTION
gpupdate /forceReapply all policy, computer and user
gpupdate /target:computer /forceComputer policy only (/target:user for user)
gpupdate /force /bootReapply and restart if a setting needs a reboot
gpupdate /force /logoffReapply and log off if a setting needs it
gpresult /rSummary of applied GPOs for the current user and computer
gpresult /r /scope computerComputer settings only (needs an elevated prompt)
gpresult /r /scope user /user <DOMAIN>\<USER>Another user’s results (admin)
gpresult /h report.htmlFull HTML report
gpresult /h report.html /fOverwrite an existing file
gpresult /s <COMPUTER> /h report.htmlReport for a remote computer
gpresult /vVerbose text output
gpresult /x report.xmlXML report

Run gpresult from an elevated prompt to include computer settings. Without elevation the computer section is empty.

GroupPolicy PowerShell Module #

Install with RSAT: Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0 (Windows 10/11) or Install-WindowsFeature GPMC (Server).

COMMANDDESCRIPTION
Get-GPO -AllList every GPO
Get-GPO -Name "<GPO>"One GPO with status and timestamps
New-GPO -Name "<GPO>" -Comment "<TEXT>"Create a GPO
New-GPLink -Name "<GPO>" -Target "OU=Workstations,DC=<DOMAIN>,DC=<TLD>" -LinkEnabled YesLink to an OU (add -Enforced Yes to enforce)
Set-GPLink -Name "<GPO>" -Target "<DN>" -LinkEnabled NoDisable a link without deleting it
Remove-GPLink -Name "<GPO>" -Target "<DN>"Remove a link
Get-GPInheritance -Target "<OU-DN>"GPOs linked and inherited at a container
Set-GPInheritance -Target "<OU-DN>" -IsBlocked YesBlock inheritance
Set-GPRegistryValue -Name "<GPO>" -Key "HKLM\Software\Policies\<VENDOR>" -ValueName <NAME> -Type DWord -Value 1Set a registry-based policy
Get-GPRegistryValue -Name "<GPO>" -Key "HKLM\Software\Policies\<VENDOR>"Read a policy value
Set-GPPermission -Name "<GPO>" -TargetName "<GROUP>" -TargetType Group -PermissionLevel GpoApplySecurity filtering (GpoRead, GpoApply, GpoEdit)
Get-GPOReport -Name "<GPO>" -ReportType Html -Path .\gpo.htmlSettings report (-All for every GPO)
Get-GPResultantSetOfPolicy -Computer <PC> -User <DOMAIN>\<USER> -ReportType Html -Path .\rsop.htmlResultant set of policy for a computer and user
Backup-GPO -All -Path D:\GPOBackupBack up all GPOs
Restore-GPO -Name "<GPO>" -Path D:\GPOBackupRestore one
Import-GPO -BackupGpoName "<GPO>" -TargetName "<NEW>" -Path D:\GPOBackup -CreateIfNeededImport a backup into another GPO
Copy-GPO -SourceName "<A>" -TargetName "<B>"Duplicate a GPO
Rename-GPO -Name "<OLD>" -TargetName "<NEW>"Rename
Remove-GPO -Name "<GPO>"Delete (unlink first)
Invoke-GPUpdate -Computer <PC> -ForcePush a refresh to a remote computer (needs firewall rules for remote scheduled tasks)

Unlinked GPOs are easy to find: Get-GPO -All | Where-Object { ($_ | Get-GPOReport -ReportType Xml) -notmatch '<LinksTo>' }.

TOOLOPEN WITHUSE
Group Policy Management (GPMC)gpmc.mscCreate, link, back up, model and view GPOs
Group Policy Management EditorRight click a GPO, EditChange settings
Group Policy ModelingGPMC, Group Policy Modeling“What if” for a user, computer, OU or site
Group Policy ResultsGPMC, Group Policy ResultsWizard for a real machine and user
Local Group Policy Editorgpedit.mscLocal policy (not on Windows Home)
Resultant Set of Policyrsop.mscLocal read-only view of applied settings
Local Security Policysecpol.mscSecurity settings subset
secedit /export /cfg sec.cfgExport current local security settings

ADMX Central Store #

ADMX files define the settings you see in the editor. By default each admin PC reads its own local copy, so different machines show different settings. A central store on SYSVOL gives every admin the same templates.

PATHCONTENTS
C:\Windows\PolicyDefinitionsLocal ADMX (*.admx) and en-US\*.adml language files
\\<DOMAIN-FQDN>\SYSVOL\<DOMAIN-FQDN>\Policies\PolicyDefinitionsCentral store (replicates to all DCs)

Create or update it by copying the templates from a current Windows build or the downloaded ADMX package:

powershell
$dom = $env:USERDNSDOMAIN
$store = "\\$dom\SYSVOL\$dom\Policies\PolicyDefinitions"
New-Item -ItemType Directory -Path $store -Force | Out-Null
Copy-Item "C:\Windows\PolicyDefinitions\*" -Destination $store -Recurse -Force
  • Keep the PolicyDefinitions folder and the en-US (or your language) subfolder together.
  • Download templates for third parties (Microsoft Edge, Office, Chrome, LAPS in the OS) and drop their .admx and .adml files in.
  • Update the store whenever you introduce a newer Windows version.
  • Check SYSVOL replication is healthy first (dcdiag /test:netlogons, repadmin /replsummary; see Active Directory).

Troubleshooting #

SYMPTOMCHECK
Policy not applyinggpresult /h report.html and read “Denied GPOs” and its reason (security filtering, WMI filter, disabled link, empty)
Computer settings missingRun gpresult elevated
Slow logonEvent ID 1503 and 1500 in Applications and Services Logs > Microsoft > Windows > GroupPolicy > Operational; look for slow links or large scripts
“The processing of Group Policy failed” (Event 1129)Network or DNS problem at startup: confirm DNS points at a DC, nltest /dsgetdc:<DOMAIN>, Test-ComputerSecureChannel
Machine in wrong OUGet-ADComputer <PC> | Select DistinguishedName
GPO linked but nothing happensVersion mismatch between AD and SYSVOL: compare in GPMC under Details; check replication
Setting is a preference, not policyGroup Policy Preferences (drive maps, printers, registry items) are item-level targeted and can be reapplied or removed; check the item’s “Apply once” and targeting
Different settings on each admin PCCreate the central store
Old or deleted setting persistsPolicy “tattoos” do not apply to preferences or non-policy keys; remove with a preference item or script
Group membership not taking effectLog off and on (users) or reboot (computers) so the access token refreshes: whoami /groups

Useful event logs and commands:

powershell
Get-WinEvent -LogName "Microsoft-Windows-GroupPolicy/Operational" -MaxEvents 30 |
  Select TimeCreated, Id, LevelDisplayName, Message
gpresult /h "$env:TEMP\gp.html" /f; Start-Process "$env:TEMP\gp.html"

The Operational event log and gpresult are usually enough. See Windows Troubleshooting for more event log queries, and Windows DNS Server for DNS records that machines need to find a DC.

Good Practice #

  • One purpose per GPO and descriptive names; avoid editing the Default Domain Policy except for password, lockout and Kerberos settings.
  • Disable the unused half (user or computer configuration) of a GPO to speed processing.
  • Test in a pilot OU before wide linking; use security filtering or WMI filters sparingly.
  • Back up with Backup-GPO -All before changes, and document each GPO’s comment field.
  • Link at OU level where possible, not the domain root.
  • Do not store passwords in Group Policy Preferences (old cpassword values are trivially decrypted).

Not Verified #

Commands were written from the Microsoft documentation and not executed against a domain. Event IDs and default refresh intervals are from documentation and may differ by Windows version.

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.