Skip to content

Instantly share code, notes, and snippets.

@vinyar
Created August 14, 2014 21:30
Show Gist options
  • Save vinyar/311c78091e7e1d1f86ff to your computer and use it in GitHub Desktop.
Save vinyar/311c78091e7e1d1f86ff to your computer and use it in GitHub Desktop.
Applying audit policies to Registry via Powreshell
# $sddl = 'O:BAG:SYD:PAI(A;CI;KA;;;CO)(A;CI;KA;;;SY)(A;CI;KA;;;BA)(A;CI;KR;;;BU)(A;CI;KR;;;AC)S:AI(AU;CISA;KA;;;WD)' # alternative just in case
$acl = get-acl HKLM:\\SOFTWARE -audit
$audit = "Everyone","FullControl","containerinherit","none","Fail"
$rule = new-object system.security.accesscontrol.registryauditrule $audit
$acl.SetAuditRule($rule)
# $acl.SetSecurityDescriptorSddlForm($sddl) # alternative just in case
set-acl -Path HKLM:\\SOFTWARE -AclObject $acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment