🏠 Home / Hub

Lesson 7 — Windows Server Security

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.

1. Windows Firewall with Advanced Security

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.

Three Firewall Profiles

ProfileWhen ActiveTypical Posture
DomainComputer is connected to AD domain network (DC is reachable)Less restrictive — managed by GPO; internal traffic trusted
PrivateNon-domain network marked as Private by user/adminModerate — home/small office use
PublicAny 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

2. Security Event IDs

The Security event log is the most important log for detecting security incidents. Memorizing key Event IDs is essential for any Windows administrator.

Authentication Events

Event IDDescriptionPriority
4624Successful logon — includes Logon Type (2=Interactive, 3=Network, 10=RemoteInteractive/RDP)Monitor
4625Failed logon — SubStatus code tells you WHY (wrong password, account locked, disabled, etc.)High — alert on repeated failures
4634Account logoffLow
4647User-initiated logoff (different from 4634)Low
4648Logon attempt using explicit credentials (RunAs, network connection with alternate creds)High — often used in pass-the-hash attacks
4779Session disconnected from remote desktopMonitor

Account Management Events

Event IDDescriptionPriority
4720User account createdHigh — alert immediately
4722User account enabledMedium
4723Password change attemptedMonitor
4724Password reset attempted by adminMonitor
4725User account disabledMedium
4726User account deletedHigh — alert immediately
4738User account changed (attributes modified)Monitor
4740Account locked outHigh — investigate source workstation
4767Account unlockedMonitor

Group Membership Events

Event IDDescriptionPriority
4728Member added to Global Security groupHigh — especially Domain Admins
4729Member removed from Global Security groupHigh
4732Member added to Local Security groupHigh
4756Member added to Universal Security groupHigh

Kerberos and System Events

Event IDDescriptionPriority
4768Kerberos TGT (Ticket-Granting Ticket) request — user authenticating to domainMonitor for failures
4769Kerberos service ticket request — accessing a specific resourceHigh volumes of failures = Kerberoasting attack
4771Kerberos pre-authentication failed (password wrong)High
1102Audit log was CLEARED — Security log wipedCRITICAL — possible attacker covering tracks
4616System time was changedHigh — time change can affect Kerberos auth
4672Special 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

3. Audit Policy Configuration

# 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
Use Advanced Audit Policy Configuration (via GPO) rather than the legacy basic Audit Policy settings. Advanced gives you per-subcategory control and does not conflict with basic settings when set correctly.

4. Windows Defender Antivirus

# 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

5. BitLocker Drive Encryption

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:"
Configuring BitLocker via GPO: Computer Config → Policies → Administrative Templates → Windows Components → BitLocker Drive Encryption. Enable "Store BitLocker recovery information in Active Directory Domain Services" to automatically back up recovery keys to AD.

6. Windows Update & WSUS

Windows Server Update Services (WSUS)

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

7. Local Security Policy and UAC

# 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

8. Credential Guard & Device Guard (Server 2016+)

These are Virtualization-Based Security (VBS) features that use Hyper-V technology to isolate sensitive OS processes.

FeatureWhat It ProtectsRequirement
Credential GuardIsolates 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 / HVCIHypervisor-Protected Code Integrity — only signed, trusted kernel-mode drivers can run. Prevents kernel rootkits.Same as Credential Guard + IOMMU/VT-d
Secured-Core ServerFull 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)

9. Microsoft Security Compliance Toolkit (SCT)

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

10. Security Hardening Checklist

#Hardening ItemHow to ImplementPriority
1Enable Windows Firewall on all profilesGPO: Windows Firewall → Domain/Private/Public profile → OnCritical
2Enable audit logging (logon, account mgmt, policy change)GPO → Advanced Audit Policy ConfigurationCritical
3Configure strong password policy (min 14 chars, complexity)Default Domain Policy → Account PoliciesCritical
4Configure account lockout (5 attempts, 15 min)Default Domain Policy → Account Lockout PolicyCritical
5Disable LM/NTLM authentication (use NTLMv2 minimum)GPO → Security Options → LAN Manager auth level = NTLMv2 onlyCritical
6Rename and disable local Administrator and Guest accountssecpol.msc or GPO → Security Options → Rename/disable accountsHigh
7Apply principle of least privilegeRemove unnecessary users from Domain Admins; use AGDLPHigh
8Enable and configure Windows DefenderEnsure real-time protection on; update signatures dailyHigh
9Keep systems patched (monthly Patch Tuesday)WSUS or Windows Update; patch within 30 days of releaseHigh
10Enable BitLocker on all drivesBitLocker Drive Encryption with TPM + recovery key to ADHigh
11Restrict RDP access by IP/subnetFirewall rule: allow RDP only from admin management subnetHigh
12Disable unnecessary servicesservices.msc → disable Print Spooler if no printing, LLMNR, NetBIOS over TCP/IPHigh
13Enable Credential GuardGPO → Device Guard → VBS → Credential Guard enabledHigh
14Disable SMBv1Set-SmbServerConfiguration -EnableSMB1Protocol $falseCritical
15Enable SMB signingGPO → Security Options → Microsoft network server: digitally sign communications (always)High
16Remove unused roles and featuresServer Manager → Remove Roles and FeaturesMedium
17Configure NTP time source correctlyPDC Emulator syncs to external NTP; all others sync to DCMedium
18Centralize and protect log files (SIEM/WEF)Windows Event Forwarding to central collector; or send to SIEMHigh
19Apply Security Baseline GPOs (Microsoft SCT)Import and link SCT baselines for servers and workstationsHigh
20Regular backup and test restoreWindows Server Backup + offsite/cloud; test restore quarterlyCritical
# 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

Lesson 7 Complete

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.

Final Lesson: Full Server Setup Lab Project →

📌 Study Checklist