A new domain controller records very little: no detail on failed sign-ins and nothing about changes to the directory. This guide switches on 24 audit settings on every domain controller, so the Security log shows who signed in, what changed and what ran.
The Security log shows who signed in, what changed in the directory and what ran.
A new domain controller records too little to spot an attack or work out what happened afterwards.
Create a policy for the Domain Controllers OU, switch on 24 audit settings and raise the log to 1 GB.
Run every step in the same PowerShell window. Later steps reuse values from earlier ones.
Create the policy
The settings live in a Group Policy object linked to the Domain Controllers OU. This step also raises the Security log to 1 GB, because more auditing fills it faster.
$dom = Get-ADDomain
New-GPO -Name 'CON-DC-Audit' -Comment 'Audit policy and Security log size for domain controllers' |
New-GPLink -Target "OU=Domain Controllers,$($dom.DistinguishedName)" | Out-Null
Set-GPRegistryValue -Name 'CON-DC-Audit' -Key 'HKLM\SYSTEM\CurrentControlSet\Control\Lsa' -ValueName 'SCENoApplyLegacyAuditPolicy' -Type DWord -Value 1 | Out-Null
Set-GPRegistryValue -Name 'CON-DC-Audit' -Key 'HKLM\SOFTWARE\Policies\Microsoft\Windows\EventLog\Security' -ValueName 'MaxSize' -Type DWord -Value 1048576 | Out-NullList the settings
These are the 24 settings. The list is Microsoft's baseline for domain controllers, plus two that help you spot an attack: Kerberos ticket requests and process creation.
| Area | Setting | Records |
|---|---|---|
| Sign-in checks | Credential Validation | Success and failure |
| Sign-in checks | Kerberos Authentication Service | Success and failure |
| Sign-in checks | Kerberos Service Ticket Operations | Success and failure |
| Accounts | User Account Management | Success and failure |
| Accounts | Computer Account Management | Success |
| Accounts | Security Group Management | Success |
| Accounts | Other Account Management Events | Success |
| Directory | Directory Service Changes | Success |
| Directory | Directory Service Access | Failure |
| Logon | Logon | Success and failure |
| Logon | Logoff | Success |
| Logon | Account Lockout | Failure |
| Logon | Special Logon | Success |
| Logon | Group Membership | Success |
| Logon | Other Logon/Logoff Events | Success and failure |
| Programs | Process Creation | Success |
| Policy | Audit Policy Change | Success |
| Policy | Authentication Policy Change | Success |
| Policy | MPSSVC Rule-Level Policy Change | Success and failure |
| Privileges | Sensitive Privilege Use | Success and failure |
| System | Security State Change | Success |
| System | Security System Extension | Success |
| System | System Integrity | Success and failure |
| System | Other System Events | Success and failure |
Paste the same list into PowerShell. Each line is a setting name, then success, then failure.
$settings = @(
@('Credential Validation','enable','enable'), @('Kerberos Authentication Service','enable','enable'),
@('Kerberos Service Ticket Operations','enable','enable'), @('Computer Account Management','enable','disable'),
@('Other Account Management Events','enable','disable'), @('Security Group Management','enable','disable'),
@('User Account Management','enable','enable'), @('Process Creation','enable','disable'),
@('Directory Service Access','disable','enable'), @('Directory Service Changes','enable','disable'),
@('Account Lockout','disable','enable'), @('Group Membership','enable','disable'),
@('Logoff','enable','disable'), @('Logon','enable','enable'),
@('Other Logon/Logoff Events','enable','enable'), @('Special Logon','enable','disable'),
@('Audit Policy Change','enable','disable'), @('Authentication Policy Change','enable','disable'),
@('MPSSVC Rule-Level Policy Change','enable','enable'), @('Sensitive Privilege Use','enable','enable'),
@('Other System Events','enable','enable'), @('Security State Change','enable','disable'),
@('Security System Extension','enable','disable'), @('System Integrity','enable','enable')
)Set them on this domain controller
This clears the current audit settings on CON-DC-01, switches on the 24, and saves them to a file.
auditpol /clear /y | Out-Null
foreach ($s in $settings) { auditpol /set /subcategory:"$($s[0])" /success:$($s[1]) /failure:$($s[2]) | Out-Null }
$tmp = "$env:TEMP\audit-export.csv"
auditpol /backup /file:$tmp | Out-Null
$rows = Import-Csv $tmp | Where-Object { $_.'Subcategory GUID' -like '{*' -and [int]$_.'Setting Value' -gt 0 }
"Settings exported: $($rows.Count)"It should say Settings exported: 24. If the number is lower, a setting name in step 2 was mistyped.
Put them in the policy
This copies the saved settings into the policy, so every domain controller gets them and keeps them.
$gpo = Get-GPO -Name 'CON-DC-Audit'
$id = $gpo.Id.ToString('B').ToUpper()
$gpoPath = "\\$env:COMPUTERNAME\SYSVOL\$($dom.DNSRoot)\Policies\$id"
# write the settings file
$dir = "$gpoPath\Machine\Microsoft\Windows NT\Audit"
New-Item -ItemType Directory -Path $dir -Force | Out-Null
$lines = @('Machine Name,Policy Target,Subcategory,Subcategory GUID,Inclusion Setting,Exclusion Setting,Setting Value')
$lines += $rows | ForEach-Object { ",System,$($_.Subcategory),$($_.'Subcategory GUID'),$($_.'Inclusion Setting'),,$($_.'Setting Value')" }
Set-Content -Path "$dir\audit.csv" -Value $lines -Encoding ASCII
# tell the policy it holds audit settings, and raise its version
$dn = "CN=$id,CN=Policies,CN=System,$($dom.DistinguishedName)"
$obj = Get-ADObject $dn -Properties gPCMachineExtensionNames, versionNumber -Server $env:COMPUTERNAME
$ext = $obj.gPCMachineExtensionNames
if ($ext -notlike '*F3CCC681*') { $ext += '[{F3CCC681-B74C-4060-9F26-CD84525DCA2A}{0F3F3735-573D-9804-99E4-AB2A69BA5FD4}]' }
$ver = $obj.versionNumber + 1
Set-ADObject $dn -Replace @{ gPCMachineExtensionNames = $ext; versionNumber = $ver } -Server $env:COMPUTERNAME
(Get-Content "$gpoPath\GPT.INI") -replace '^Version=\d+', "Version=$ver" | Set-Content "$gpoPath\GPT.INI" -Encoding ASCIIApply it to every domain controller
The pause gives the policy time to copy to the other domain controllers.
$dcs = (Get-ADDomainController -Filter *).HostName
repadmin /syncall /AdeP | Select-String 'error|terminated'
Start-Sleep -Seconds 90
Invoke-Command -ComputerName $dcs -ScriptBlock {
gpupdate /force | Out-Null
wevtutil sl Security /ms:1073741824
}The wevtutil line sets the log size straight away. Without it, the log stays at its old size until the Event Log service next restarts.
Check every domain controller
Invoke-Command -ComputerName $dcs -ScriptBlock {
$on = auditpol /get /category:* | Select-String 'Success|Failure'
[pscustomobject]@{
SettingsOn = @($on).Count
LogMaxBytes = (Get-WinEvent -ListLog Security).MaximumSizeInBytes
}
} | Format-Table PSComputerName, SettingsOn, LogMaxBytes -AutoSize| Column | What you want |
|---|---|
| SettingsOn | 24 on every domain controller. |
| LogMaxBytes | 1073741824, which is 1 GB. |
CON-DC-01 shows 24 whatever happens, because step 3 set it directly. The other domain controllers only get the settings through the policy. If one shows fewer than 24, wait five minutes and run steps 5 and 6 again.
What you can now see
Open Event Viewer › Windows Logs › Security on a domain controller and filter by event ID.
| Event ID | What happened |
|---|---|
| 4625 | A sign-in failed. |
| 4740 | An account was locked out. |
| 4720 | A user account was created. |
| 4728, 4732, 4756 | Someone was added to a security group. |
| 5136 | An object in the directory was changed. |
| 4769 | A Kerberos service ticket was requested. |
| 4688 | A program started. |
Things to know
- Any audit setting not in the list is switched off. When a policy supplies audit settings, Windows clears the rest first.
- The log fills faster than before. If it stops reaching back far enough, raise
MaxSizein the policy or send the events to a log collector. - To change a setting later, edit the policy in Group Policy Management under Computer Configuration › Policies › Windows Settings › Security Settings › Advanced Audit Policy Configuration.
Done when
Every domain controller shows 24 settings and a 1 GB Security log, and a failed sign-in appears in the log as event 4625.


