Guide

Audit domain security

Before you harden anything, find out what you have. These read-only commands show the password policy, who holds admin rights, risky account settings and how each domain controller is set up. Nothing is changed.

15 minutesRun as a domain admin on CON-DC-01
What improves

You know where the domain stands before you change anything.

Why it matters

Hardening without a baseline wastes effort and can miss the biggest gaps.

How you do it

Run read-only commands for policies, admin groups, risky accounts and DC settings.

Domain settings

CON-DC-01
$dom = Get-ADDomain
Get-ADForest | Format-List Name, ForestMode
Get-ADOptionalFeature -Filter * | Format-Table Name, EnabledScopes -AutoSize
"Machine account quota: " + (Get-ADObject $dom.DistinguishedName -Properties 'ms-DS-MachineAccountQuota').'ms-DS-MachineAccountQuota'

Password and lockout policy

CON-DC-01
Get-ADDefaultDomainPasswordPolicy | Format-List MinPasswordLength, PasswordHistoryCount, ComplexityEnabled, MaxPasswordAge, LockoutThreshold, LockoutDuration
Get-ADFineGrainedPasswordPolicy -Filter * | Format-Table Name, Precedence, MinPasswordLength, LockoutThreshold -AutoSize

Who holds admin rights

CON-DC-01
foreach ($g in 'Domain Admins','Enterprise Admins','Schema Admins','Administrators','Account Operators','Backup Operators','Server Operators','Print Operators','DnsAdmins','Group Policy Creator Owners','Protected Users') {
    $m = Get-ADGroupMember -Identity $g -Recursive -ErrorAction SilentlyContinue
    "{0,-28} {1}" -f $g, (($m | ForEach-Object { $_.SamAccountName }) -join ', ')
}

Risky account settings

Each list should be short or empty.

CON-DC-01
"Password never expires:"
Get-ADUser -Filter 'PasswordNeverExpires -eq $true -and Enabled -eq $true' | ForEach-Object { "  " + $_.SamAccountName }
"Password not required:"
Get-ADUser -Filter 'PasswordNotRequired -eq $true' | ForEach-Object { "  " + $_.SamAccountName }
"No Kerberos pre-authentication:"
Get-ADUser -Filter 'DoesNotRequirePreAuth -eq $true' | ForEach-Object { "  " + $_.SamAccountName }
"Reversible encryption:"
Get-ADUser -Filter 'AllowReversiblePasswordEncryption -eq $true' | ForEach-Object { "  " + $_.SamAccountName }
"User accounts with an SPN:"
Get-ADUser -Filter 'ServicePrincipalName -like "*"' | Where-Object SamAccountName -ne 'krbtgt' | ForEach-Object { "  " + $_.SamAccountName }
"Computers trusted for unconstrained delegation (not DCs):"
Get-ADComputer -Filter 'TrustedForDelegation -eq $true' -Properties PrimaryGroupID | Where-Object { $_.PrimaryGroupID -notin 516,521 } | ForEach-Object { "  " + $_.Name }

Settings on each domain controller

CON-DC-01
Invoke-Command -ComputerName (Get-ADDomainController -Filter *).HostName -ScriptBlock {
    $lsa  = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa'
    $ntds = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\NTDS\Parameters'
    $smb  = Get-SmbServerConfiguration
    $spl  = Get-Service Spooler
    [pscustomobject]@{
        LastUpdate         = (Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 1).InstalledOn
        SMB1Enabled        = $smb.EnableSMB1Protocol
        SMBSigningRequired = $smb.RequireSecuritySignature
        LDAPSigning        = $ntds.LDAPServerIntegrity
        LsaProtection      = $lsa.RunAsPPL
        PrintSpooler       = "$($spl.Status) / $($spl.StartType)"
    }
} | Format-List PSComputerName, LastUpdate, SMB1Enabled, SMBSigningRequired, LDAPSigning, LsaProtection, PrintSpooler

A blank value means the setting has never been configured and Windows is using its default.

What to look for

ResultWhat it meansGuide
Machine account quota is 10Any user can join ten computers to the domain.Stop users joining computers to the domain
Lockout threshold is 0Passwords can be guessed without limit.Set password and lockout policies
Minimum length under 14Short passwords are allowed.Set password and lockout policies
Only Administrator in Domain AdminsOne shared account does everything.Create a named domain admin account
Members in Schema Admins or Enterprise AdminsForest-wide rights are held all the time.Empty Schema Admins and Enterprise Admins
Print Spooler is RunningA service DCs do not need is exposed.Turn off Print Spooler on domain controllers
Recycle Bin has no enabled scopesDeleted accounts cannot be restored easily.Finish the domain setup
LastUpdate is months oldThe server is missing security updates.Run Windows Update, one DC at a time.

Done when

Check

You have the output saved somewhere safe and a list of what to fix first.

Your progress is kept in this browser only.