A system access control list decides which operations on an object are eligible for auditing. Windows audit policy decides whether events are actually written. Both have to be right before an event appears in the security log.
Audit rules exist for the file system, registry keys, services and the SCM, and live processes. SMB shares, Active Directory objects, Task Scheduler objects, and certificate private keys expose no audit rules in this module.
Every SACL read and write requires SeSecurityPrivilege:
Get-WindowsPrivilege
Test-WindowsPrivilege -Name SeSecurityPrivilegeThe module temporarily enables the privilege when it is present in the process token and restores its original state afterwards. It cannot add a privilege the token does not contain, so run the operation from a process whose token holds it. See Safety, preview, and privileges.
Audit failed writes by Everyone on a directory and its children:
Add-NTFSAuditRule -LiteralPath 'C:\Data' `
-Account 'S-1-1-0' `
-AccessRights Write `
-AuditFlags Failure `
-AppliesTo ThisFolderSubfoldersAndFiles `
-WhatIfInspect and remove exactly what is there:
Get-NTFSAuditRule -LiteralPath 'C:\Data' -ExcludeInherited
Get-NTFSAuditRule -LiteralPath 'C:\Data' -Account 'S-1-1-0' -ExcludeInherited |
Remove-NTFSAuditRule -WhatIfClear-NTFSAuditRule removes every explicit audit rule from the selected
items.
| Value | Records |
|---|---|
Success |
Successful attempts |
Failure |
Denied attempts |
Success, Failure |
Both |
Failure is the higher-signal choice for detecting a misconfiguration or an
unauthorized attempt. Success on a busy path can produce a very large volume
of events.
The audit commands follow the same shape everywhere:
Add-RegistryKeyAuditRule -Path 'HKLM:\Software\Contoso' `
-Account 'S-1-1-0' `
-AccessRights SetValue `
-AuditFlags Failure `
-WhatIf
Add-ServiceAuditRule -Name BITS `
-Account 'S-1-1-0' `
-ServiceRights ChangeConfig `
-AuditFlags Failure `
-WhatIf
Add-ProcessAuditRule -InputObject $PID `
-Account 'S-1-1-0' `
-ProcessRights Terminate `
-AuditFlags Success `
-WhatIfEach family uses its own rights parameter: AccessRights for the file system
and registry, ServiceRights or ControlManagerRights for services and the
SCM, and ProcessRights for processes.
The file system and registry families expose the audit section separately from the access section, so audit inheritance can be changed on its own:
Get-NTFSItemInheritance -LiteralPath 'C:\Data' -Section Audit
Disable-NTFSItemInheritance -LiteralPath 'C:\Data' `
-Section Audit `
-WhatIf
Disable-RegistryKeyInheritance -Path 'HKLM:\Software\Contoso' `
-Section Audit `
-PreserveInherited $trueServices, the SCM, and processes have no inheritance at all.
A SACL alone produces nothing. The matching Windows object access audit policy subcategory has to be enabled as well, which this module does not manage:
auditpol.exe /get /category:"Object Access"Enable the applicable subcategory through Group Policy or auditpol.exe, then
verify that events appear in the security log.
Work through this in order:
- Confirm the audit rule is present and explicit:
Get-NTFSAuditRule -LiteralPath $path -ExcludeInherited. - Confirm the audit flag matches what you expect to see: a denied attempt
produces nothing when only
Successis audited. - Confirm the object access audit policy subcategory is enabled.
- Confirm the operation actually reached the object. Access denied by a share permission never reaches the file system SACL.
A selected absent SACL is encoded explicitly in a backup as
S:NO_ACCESS_CONTROL, which is different from an empty protected SACL (S:P).
The first can inherit audit rules later; the second cannot. Use the second when
audit inheritance must remain empty. See
Backup, restore, and copy.
| Family | Commands |
|---|---|
| File system | New-NTFSAuditRule, Get-NTFSAuditRule, Add-NTFSAuditRule, Set-NTFSAuditRule, Remove-NTFSAuditRule, Clear-NTFSAuditRule |
| Registry | Get-RegistryKeyAuditRule, Add-RegistryKeyAuditRule, Set-RegistryKeyAuditRule, Remove-RegistryKeyAuditRule, Clear-RegistryKeyAuditRule |
| Service and SCM | Get-ServiceAuditRule, Add-ServiceAuditRule, Set-ServiceAuditRule, Remove-ServiceAuditRule, Clear-ServiceAuditRule |
| Process | Get-ProcessAuditRule, Add-ProcessAuditRule, Set-ProcessAuditRule, Remove-ProcessAuditRule, Clear-ProcessAuditRule |
| Privileges | Get-WindowsPrivilege, Test-WindowsPrivilege, Enable-WindowsPrivilege, Disable-WindowsPrivilege |