Permissions, auditing and change tracking
Read and change registry ACLs, audit who changes sensitive keys, and track drift across servers.
Registry keys have ACLs
Every key has a security descriptor like a folder: owner, permissions (Full Control, Read, and special permissions such as Set Value, Create Subkey) and auditing entries. Values inherit their key's permissions. View them with Regedit (Edit > Permissions) or PowerShell:
Get-Acl 'HKLM:\SOFTWARE\Contoso' | Format-List Owner, AccessToString
# give a service account write access to one key
$acl = Get-Acl 'HKLM:\SOFTWARE\Contoso\App'
$rule = New-Object System.Security.AccessControl.RegistryAccessRule('CONTOSO\svc-app','SetValue,CreateSubKey,ReadKey','ContainerInherit','None','Allow')
$acl.AddAccessRule($rule)
Set-Acl 'HKLM:\SOFTWARE\Contoso\App' $acl
Don't loosen permissions on Windows keys (Services, Run, Winlogon, Lsa). If an app needs write access to HKLM, grant it on that app's own key only.
Audit changes with the Security log
- Enable the audit policy: Advanced Audit Policy Configuration > Object Access > Audit Registry (Success), or
auditpol /set /subcategory:"Registry" /success:enable. - Add an auditing entry (SACL) on the key: Regedit > Permissions > Advanced > Auditing, principal Everyone, Set Value / Create Subkey / Delete.
- Read the Security log: event 4657 (a registry value was modified) and 4663 (an attempt was made to access an object).
Audit only sensitive keys; auditing big branches floods the log. For continuous monitoring across many machines, Sysmon events 12, 13 and 14 with a focused configuration are easier to manage.
Track drift across servers
# export the same branch from every VDA and compare against a reference
$ref = Invoke-Command vda01 { Get-ItemProperty 'HKLM:\SOFTWARE\FSLogix\Profiles' }
Invoke-Command vda02, vda03 {
Get-ItemProperty 'HKLM:\SOFTWARE\FSLogix\Profiles'
} | ForEach-Object {
$cmp = Compare-Object $ref.PSObject.Properties.Where{ $_.Name -notlike 'PS*' } `
$_.PSObject.Properties.Where{ $_.Name -notlike 'PS*' } -Property Name, Value
if ($cmp) { "$($_.PSComputerName) differs:"; $cmp }
}
reg compare \\srv01\HKLM\... \\srv02\HKLM\... /s does the same without PowerShell. For permanent enforcement, move the setting into Group Policy, Intune or a Configuration Manager baseline.
References: Audit Registry, Event 4657, RegistryAccessRule.