Security is not a single feature — it's a layered approach (defense in depth). This lesson covers Windows Firewall, Security Event IDs, auditing, Windows Defender, BitLocker, Windows Update/WSUS, and a practical hardening checklist.
Windows Firewall with Advanced Security (wf.msc) is a stateful host firewall built into Windows Server. It controls network traffic at the OS level, independent of any perimeter firewall.
| Profile | When Active | Typical Posture |
|---|---|---|
| Domain | Computer is connected to AD domain network (DC is reachable) | Less restrictive — managed by GPO; internal traffic trusted |
| Private | Non-domain network marked as Private by user/admin | Moderate — home/small office use |
| Public | Any unrecognized network (hotel, coffee shop, unknown) | Most restrictive — blocks almost everything inbound |
# View firewall status on all profiles
Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundAction
# Enable/disable all profiles
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
# --- Create Firewall Rules ---
# Allow a specific application (inbound)
New-NetFirewallRule -DisplayName "Allow MyApp Inbound" `
-Direction Inbound -Program "C:\Apps\myapp.exe" -Action Allow -Profile Domain
# Allow a TCP port (inbound)
New-NetFirewallRule -DisplayName "Allow HTTPS Inbound" `
-Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow -Profile Domain,Private
# Block outbound to a specific IP (e.g., block access to known malicious IP)
New-NetFirewallRule -DisplayName "Block Malicious IP" `
-Direction Outbound -RemoteAddress "10.99.99.99" -Action Block
# Allow RDP only from specific subnet
New-NetFirewallRule -DisplayName "RDP from Admin Network Only" `
-Direction Inbound -Protocol TCP -LocalPort 3389 `
-RemoteAddress "192.168.10.0/24" -Action Allow
# View existing rules
Get-NetFirewallRule | Where-Object {$_.Enabled -eq "True" -and $_.Direction -eq "Inbound"} |
Select-Object DisplayName, Action, Profile | Sort-Object DisplayName
# Disable a rule (instead of deleting)
Disable-NetFirewallRule -DisplayName "Allow HTTPS Inbound"
# netsh commands (legacy but still useful in scripts)
netsh advfirewall show allprofiles
netsh advfirewall firewall add rule name="Allow SQL" protocol=TCP dir=in localport=1433 action=allow
netsh advfirewall export "C:\Firewall-Backup.wfw" # Export all rules
netsh advfirewall import "C:\Firewall-Backup.wfw" # Import rules
The Security event log is the most important log for detecting security incidents. Memorizing key Event IDs is essential for any Windows administrator.
| Event ID | Description | Priority |
|---|---|---|
| 4624 | Successful logon — includes Logon Type (2=Interactive, 3=Network, 10=RemoteInteractive/RDP) | Monitor |
| 4625 | Failed logon — SubStatus code tells you WHY (wrong password, account locked, disabled, etc.) | High — alert on repeated failures |
| 4634 | Account logoff | Low |
| 4647 | User-initiated logoff (different from 4634) | Low |
| 4648 | Logon attempt using explicit credentials (RunAs, network connection with alternate creds) | High — often used in pass-the-hash attacks |
| 4779 | Session disconnected from remote desktop | Monitor |
| Event ID | Description | Priority |
|---|---|---|
| 4720 | User account created | High — alert immediately |
| 4722 | User account enabled | Medium |
| 4723 | Password change attempted | Monitor |
| 4724 | Password reset attempted by admin | Monitor |
| 4725 | User account disabled | Medium |
| 4726 | User account deleted | High — alert immediately |
| 4738 | User account changed (attributes modified) | Monitor |
| 4740 | Account locked out | High — investigate source workstation |
| 4767 | Account unlocked | Monitor |
| Event ID | Description | Priority |
|---|---|---|
| 4728 | Member added to Global Security group | High — especially Domain Admins |
| 4729 | Member removed from Global Security group | High |
| 4732 | Member added to Local Security group | High |
| 4756 | Member added to Universal Security group | High |
| Event ID | Description | Priority |
|---|---|---|
| 4768 | Kerberos TGT (Ticket-Granting Ticket) request — user authenticating to domain | Monitor for failures |
| 4769 | Kerberos service ticket request — accessing a specific resource | High volumes of failures = Kerberoasting attack |
| 4771 | Kerberos pre-authentication failed (password wrong) | High |
| 1102 | Audit log was CLEARED — Security log wiped | CRITICAL — possible attacker covering tracks |
| 4616 | System time was changed | High — time change can affect Kerberos auth |
| 4672 | Special privileges assigned to new logon (admin rights used) | Monitor for non-admin accounts |
# Query security events via PowerShell
# Find all failed logons in the last hour
$start = (Get-Date).AddHours(-1)
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=$start} |
ForEach-Object {
$xml = [xml]$_.ToXml()
[PSCustomObject]@{
Time = $_.TimeCreated
Account = $xml.Event.EventData.Data[5].'#text'
Domain = $xml.Event.EventData.Data[6].'#text'
Source = $xml.Event.EventData.Data[19].'#text'
FailCode = $xml.Event.EventData.Data[7].'#text'
}
} | Format-Table -AutoSize
# Alert: Someone added a member to Domain Admins
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4728} |
Where-Object {$_.Message -like "*Domain Admins*"} |
Select-Object TimeCreated, Message | Format-List
# CRITICAL: Check if audit log was cleared (Event ID 1102)
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=1102} |
Select-Object TimeCreated, Message
# Check current audit policy auditpol /get /category:* # Set specific audit policies (run as admin) auditpol /set /subcategory:"Logon" /success:enable /failure:enable auditpol /set /subcategory:"Account Logon" /success:enable /failure:enable auditpol /set /subcategory:"User Account Management" /success:enable /failure:enable auditpol /set /subcategory:"Security Group Management" /success:enable /failure:enable auditpol /set /subcategory:"Audit Policy Change" /success:enable /failure:enable auditpol /set /subcategory:"System Integrity" /success:enable /failure:enable # Export audit policy to a file (for backup/import to other servers) auditpol /backup /file:C:\Audit-Policy-Backup.csv auditpol /restore /file:C:\Audit-Policy-Backup.csv # View advanced audit policy (more granular than basic) # GPO: Computer Config → Policies → Windows Settings → Security Settings → # Advanced Audit Policy Configuration
# Check Windows Defender status Get-MpComputerStatus | Select-Object AMServiceEnabled, AntispywareEnabled, ` AntivirusEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated, ` QuickScanAge, FullScanAge # Update definitions Update-MpSignature # Run a quick scan Start-MpScan -ScanType QuickScan # Run a full scan Start-MpScan -ScanType FullScan # Scan a specific path Start-MpScan -ScanType CustomScan -ScanPath "C:\Downloads" # View recent threats detected Get-MpThreatDetection | Select-Object ThreatID, Resources, ActionSuccess, InitialDetectionTime # View threat history Get-MpThreat | Select-Object ThreatName, SeverityID, IsActive, DetectionID # Configure exclusions (e.g., exclude SQL Server data directory — database files) Add-MpPreference -ExclusionPath "D:\SQLData" Add-MpPreference -ExclusionProcess "sqlservr.exe" Add-MpPreference -ExclusionExtension ".mdf" # Be careful with file extension exclusions # View current exclusions Get-MpPreference | Select-Object ExclusionPath, ExclusionProcess, ExclusionExtension # Configure via GPO: Computer Config → Policies → Administrative Templates → # Windows Components → Microsoft Defender Antivirus
BitLocker encrypts the entire drive to protect data if the physical drive is stolen or the server is decommissioned without proper data wiping.
# Check BitLocker status on all drives
Get-BitLockerVolume | Select-Object MountPoint, VolumeStatus, ProtectionStatus, `
EncryptionPercentage, KeyProtector
# Enable BitLocker on C: with TPM protector
Enable-BitLocker -MountPoint "C:" -TpmProtector
# Add a recovery key protector (numeric recovery password)
Add-BitLockerKeyProtector -MountPoint "C:" -RecoveryPasswordProtector
# Get the recovery password (SAVE THIS!)
(Get-BitLockerVolume "C:").KeyProtector | Where-Object {$_.KeyProtectorType -eq "RecoveryPassword"} |
Select-Object KeyProtectorId, RecoveryPassword
# Backup recovery key to Active Directory (highly recommended)
Backup-BitLockerKeyProtector -MountPoint "C:" `
-KeyProtectorId (Get-BitLockerVolume "C:").KeyProtector[1].KeyProtectorId
# Check if BitLocker key is stored in AD:
# In ADUC with Advanced Features → Computer object → BitLocker Recovery tab
# Encrypt an additional data drive (non-OS drive) with auto-unlock
Enable-BitLocker -MountPoint "D:" -RecoveryPasswordProtector
Enable-BitLockerAutoUnlock -MountPoint "D:"
# Suspend BitLocker temporarily (for BIOS update, etc.)
Suspend-BitLocker -MountPoint "C:" -RebootCount 1 # Re-enables after 1 reboot
# Disable BitLocker (decrypts drive — takes time)
Disable-BitLocker -MountPoint "C:"
WSUS lets administrators control which updates are downloaded, tested, and deployed to computers in the domain. This prevents uncontrolled updates from breaking production systems.
# Install WSUS role (needs sufficient disk space — minimum 30 GB recommended)
Install-WindowsFeature -Name UpdateServices, UpdateServices-WidDB, `
UpdateServices-Services, UpdateServices-RSAT, UpdateServices-API, `
UpdateServices-UI -IncludeManagementTools
# Initial WSUS configuration (run after install)
CD "C:\Program Files\Update Services\Tools"
.\wsusutil.exe postinstall CONTENT_DIR=D:\WSUS
# Configure clients to use WSUS via GPO:
# Computer Config → Policies → Administrative Templates → Windows Components → Windows Update
# "Specify intranet Microsoft update service location":
# Set update service URL: http://WSUS-SERVER:8530
# Set statistics server URL: http://WSUS-SERVER:8530
# "Configure Automatic Updates": 4 = Auto download and schedule install
# "Automatic Updates detection frequency": 4 hours
# PowerShell: Check Windows Update status on a server
$wu = New-Object -ComObject "Microsoft.Update.Session"
$searcher = $wu.CreateUpdateSearcher()
$result = $searcher.Search("IsInstalled=0") # Find uninstalled updates
$result.Updates | Select-Object Title, MsrcSeverity | Format-Table
# Force Windows Update check (client)
wuauclt /detectnow
wuauclt /reportnow
# Get update history (last 20 updates installed)
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 20 |
Select-Object HotFixID, Description, InstalledOn
# Open Local Security Policy (member server without domain, or for local settings) secpol.msc # Key Security Options (Computer Config → Windows Settings → Security Settings → Local Policies → Security Options): # Interactive logon: Do not display last user name = Enabled (don't show who logged in last) # Interactive logon: Machine inactivity limit = 900 seconds (lock after 15 min idle) # Network access: Do not allow anonymous enumeration of SAM accounts = Enabled # Network security: LAN Manager authentication level = Send NTLMv2 only (disable LM/NTLM) # Accounts: Rename administrator account = (change from "Administrator" to something else) # Accounts: Rename guest account = (then disable Guest) # UAC (User Account Control) levels: # Registry: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System # ConsentPromptBehaviorAdmin: # 0 = No prompt (always elevated — NOT RECOMMENDED) # 1 = Prompt for credentials on secure desktop # 2 = Prompt for consent on secure desktop (default for Admins) # 5 = Prompt for consent for non-Windows binaries # Check UAC level via PowerShell Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" | Select-Object EnableLUA, ConsentPromptBehaviorAdmin, ConsentPromptBehaviorUser # Ensure UAC is enabled: Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" ` -Name EnableLUA -Value 1
These are Virtualization-Based Security (VBS) features that use Hyper-V technology to isolate sensitive OS processes.
| Feature | What It Protects | Requirement |
|---|---|---|
| Credential Guard | Isolates LSASS (credential store) in a secure, hardware-virtualized container. Prevents Pass-the-Hash and Pass-the-Ticket attacks even if an attacker has SYSTEM access. | UEFI, Secure Boot, 64-bit CPU with VT-x/AMD-V, TPM 1.2+ |
| Device Guard / HVCI | Hypervisor-Protected Code Integrity — only signed, trusted kernel-mode drivers can run. Prevents kernel rootkits. | Same as Credential Guard + IOMMU/VT-d |
| Secured-Core Server | Full stack of security features built in from hardware up (TPM 2.0, Secure Boot, HVCI, Credential Guard all pre-enabled) | Server 2022 with compatible hardware (labeled "Secured-core") |
# Enable Credential Guard via registry (Server 2016/2019/2022) # OR via GPO: Computer Config → Policies → Administrative Templates → # System → Device Guard → Turn On Virtualization Based Security # Credential Guard Configuration: Enabled with UEFI lock # Verify Credential Guard status Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard | Select-Object VirtualizationBasedSecurityStatus, SecurityFeaturesRunning # Status values: # 0 = Not running # 1 = Running (look for "CredentialGuard" in SecurityFeaturesRunning)
The Security Compliance Toolkit (successor to MBSA) is a free Microsoft tool providing security baselines — pre-configured GPO settings aligned with CIS Benchmarks and Microsoft hardening guidance.
# Import Security Baseline GPOs into your domain (from SCT download): # 1. Extract the baseline zip # 2. Run the "Baseline-ADImport.ps1" script from the Scripts folder # 3. The script imports baseline GPOs into your domain # 4. Link them to appropriate OUs (test first!) # Use Policy Analyzer to compare settings: PolicyAnalyzer.exe # File → Add Files to Compare → add your current GPO backup vs baseline XML
| # | Hardening Item | How to Implement | Priority |
|---|---|---|---|
| 1 | Enable Windows Firewall on all profiles | GPO: Windows Firewall → Domain/Private/Public profile → On | Critical |
| 2 | Enable audit logging (logon, account mgmt, policy change) | GPO → Advanced Audit Policy Configuration | Critical |
| 3 | Configure strong password policy (min 14 chars, complexity) | Default Domain Policy → Account Policies | Critical |
| 4 | Configure account lockout (5 attempts, 15 min) | Default Domain Policy → Account Lockout Policy | Critical |
| 5 | Disable LM/NTLM authentication (use NTLMv2 minimum) | GPO → Security Options → LAN Manager auth level = NTLMv2 only | Critical |
| 6 | Rename and disable local Administrator and Guest accounts | secpol.msc or GPO → Security Options → Rename/disable accounts | High |
| 7 | Apply principle of least privilege | Remove unnecessary users from Domain Admins; use AGDLP | High |
| 8 | Enable and configure Windows Defender | Ensure real-time protection on; update signatures daily | High |
| 9 | Keep systems patched (monthly Patch Tuesday) | WSUS or Windows Update; patch within 30 days of release | High |
| 10 | Enable BitLocker on all drives | BitLocker Drive Encryption with TPM + recovery key to AD | High |
| 11 | Restrict RDP access by IP/subnet | Firewall rule: allow RDP only from admin management subnet | High |
| 12 | Disable unnecessary services | services.msc → disable Print Spooler if no printing, LLMNR, NetBIOS over TCP/IP | High |
| 13 | Enable Credential Guard | GPO → Device Guard → VBS → Credential Guard enabled | High |
| 14 | Disable SMBv1 | Set-SmbServerConfiguration -EnableSMB1Protocol $false | Critical |
| 15 | Enable SMB signing | GPO → Security Options → Microsoft network server: digitally sign communications (always) | High |
| 16 | Remove unused roles and features | Server Manager → Remove Roles and Features | Medium |
| 17 | Configure NTP time source correctly | PDC Emulator syncs to external NTP; all others sync to DC | Medium |
| 18 | Centralize and protect log files (SIEM/WEF) | Windows Event Forwarding to central collector; or send to SIEM | High |
| 19 | Apply Security Baseline GPOs (Microsoft SCT) | Import and link SCT baselines for servers and workstations | High |
| 20 | Regular backup and test restore | Windows Server Backup + offsite/cloud; test restore quarterly | Critical |
# Quick hardening commands — run on every new server
# Disable SMBv1 (forever)
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
# Enable SMB signing (required — prevents man-in-the-middle)
Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
Set-SmbClientConfiguration -RequireSecuritySignature $true -Force
# Disable NetBIOS over TCP/IP on all adapters (reduces attack surface)
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled=True"
$adapters | ForEach-Object { $_.SetTcpipNetbios(2) } # 2 = Disable NetBIOS
# Disable LLMNR (Link-Local Multicast Name Resolution — used in Responder attacks)
# Via GPO: Computer Config → Admin Templates → Network → DNS Client
# "Turn off multicast name resolution" → Enabled
# Via registry:
New-Item "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Force
Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" `
-Name EnableMulticast -Value 0
# Ensure TLS 1.0 and 1.1 are disabled (use TLS 1.2+ only)
# Use IIS Crypto tool (GUI) or manually via registry:
# HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server
# Enabled = 0, DisabledByDefault = 1
You now understand Windows Firewall rule creation, can read critical Security Event IDs to detect incidents, configure audit policies, manage Windows Defender and BitLocker, control Windows Updates with WSUS, and apply a comprehensive 20-point hardening checklist.