Between 2021 and 2023, vulnerabilities in the Windows Print Spooler (CVE-2021-34527, CVE-2022-22718) provided domain admin privileges to attackers on patched systems. The root issue: unnecessary services running by default on servers that never touch a printer. This lesson provides a definitive methodology to identify, disable, and harden Windows services—including SMBv1, RDP, and Windows Search—to eliminate entire classes of attacks.
1. Inventory all running services with Get-Service | Where-Object {$_.Status -eq 'Running'}. 2. Map each service to the server's role: a web server does not need Print Spooler or Server service. 3. Set unnecessary services to Disabled via sc config or Group Policy. 4. Test application functionality thoroughly; some applications have hidden dependencies. 5. Document the disabled services in the baseline image for audit traceability.
# List all running services and export to CSV
Get-Service | Where-Object {$_.Status -eq "Running"} | Select Name, DisplayName, StartType | Export-Csv -Path services.csv -NoTypeInformation
# Disable a service
Stop-Service -Name Spooler -Force
Set-Service -Name Spooler -StartupType DisabledThis approach stops the service immediately and prevents it from restarting on next boot. The CSV provides an audit trail.
Print Spooler (Spooler), SMBv1 (disabled via Features or registry), Remote Registry (RemoteRegistry), Windows Search (WSearch), and XPS Services are top candidates for servers. Also consider disabling the Server service (LanmanServer) on a purely client machine—this removes the ability to share folders, closing an entire attack vector. Each disabled service reduces the attack surface and frees up resources.
💡 The Server service (LanmanServer) is distinct from SMBv1. You can disable SMBv1 while keeping SMB2/3 active for file sharing. But if the machine never shares files, disable LanmanServer entirely.
| Service | Display Name | Recommended Action on Server |
|---|---|---|
| Spooler | Print Spooler | Disable unless server is a print server |
| LanmanServer | Server | Disable if no file sharing needed |
| RemoteRegistry | Remote Registry | Always disable |
| WSearch | Windows Search | Disable on web/database servers |
| XblGameSave | Xbox Live Game Save | Disable on all servers |
Disabling the Remote Desktop Services service (TermService) is the ultimate RDP lockout, but if RDP is required, enforce Network Level Authentication (NLA), set an account lockout policy, and use RDP gateways or VPNs instead of directly exposing 3389. Additionally, restrict the 'Remote Desktop Users' group and set interactive logon timeouts.
⚠️ Disabling the Server service on a machine that is also an AD domain controller breaks replication. Understand the role before disabling.
Verify exercises to earn ★ 140 XP and unlock next lab level.