Ransomware continues to evolve, targeting everything from personal laptops to enterprise servers. While no single setting can guarantee 100% immunity, a layered hardening strategy can dramatically reduce the attack surface on Windows machines. This guide walks you through eight concrete steps—complete with PowerShell commands, Group Policy tweaks, and backup best practices—to turn a default Windows installation into a resilient fortress.
What You’ll Need
- Windows 10 / 11 (Pro, Enterprise, or Education) with administrative rights
- PowerShell 5.1+ (or PowerShell 7 for optional modules)
- Microsoft Security Compliance Toolkit (optional but recommended)
- Access to a network share or external storage for immutable backups
- Basic familiarity with Group Policy Management Console (gpmc.msc)
Step 1: Enable Controlled Folder Access (CFA)
Controlled Folder Access, part of Windows Defender Exploit Guard, blocks unauthorized apps from writing to protected directories. Open PowerShell as admin and run:
Set-MpPreference -EnableControlledFolderAccess Enabled
Next, add the folders you want to protect (e.g., Documents, Desktop, Pictures):
$folders = @("C:\Users\$env:USERNAME\Documents","C:\Users\$env:USERNAME\Desktop","C:\Users\$env:USERNAME\Pictures")
foreach ($f in $folders) { Add-MpControlledFolderAccessRule -Folder $f } If a legitimate app is blocked, you can whitelist it with:
Add-MpPreference -ControlledFolderAccessAllowedApplications "C:\Program Files\YourApp\app.exe"
Remember to keep the list lean; over‑whitelisting defeats the purpose.
Step 2: Configure Windows Defender Exploit Guard (Attack Surface Reduction Rules)
Exploit Guard offers a set of Attack Surface Reduction (ASR) rules that mitigate common ransomware tactics. Apply the recommended baseline with PowerShell:
Set-MpPreference -AttackSurfaceReductionRules_Ids "D4F940AB-401B-4efc-aadc-936c9e5b9d0e"=1 "D3E037E1-3EB8-44c8-A917-579E1D5C5F5F"=1 "26190899-1602-49e8-8b27-eb1d0a1c6d0e"=1 "3B576869-A4EC-4529-8536-9E2B4A0B5F6A"=1
Each rule ID corresponds to a specific mitigation (e.g., block executable content from email, block Office macros from the internet). Use Get-MpPreference to verify the settings.
Step 3: Harden PowerShell Execution Policy
PowerShell is a favorite ransomware delivery vector. Enforce a restrictive execution policy and enable script block logging:
Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope LocalMachine -Force Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableScriptBlockLogging" -Value 1 -Type DWord Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableTranscripting" -Value 1 -Type DWord New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcripts" -Force
All scripts must be signed by a trusted publisher, and every command line is logged to %SystemRoot%System32WindowsPowerShellv1.0Transcripts. Review logs regularly with Get-Content or a SIEM.
Step 4: Apply Microsoft Security Baselines via LGPO
The Security Compliance Toolkit ships ready‑made Group Policy Objects (GPOs) that harden Windows against ransomware. Download the latest Security Baseline for Windows 10/11, extract, then import with LGPO.exe:
lgpo.exe /b "C:\Baseline\Windows10" /t machine
This command applies the baseline to the local machine. For domain‑joined PCs, import the .admx files into your central GPO and link the policy to the appropriate OU. Pay special attention to the “Network security: LAN Manager authentication level” and “System cryptography: Use FIPS compliant algorithms” settings.
Step 5: Implement Application Whitelisting with AppLocker
AppLocker allows you to define which executables, scripts, and DLLs are permitted to run. Create a default-deny rule set and then add explicit allow rules for trusted software.
# Create a new AppLocker policy XML skeleton New-AppLockerPolicy -RuleType All -User Everyone -Xml > C:\Policies\AppLocker.xml # Edit the XML to keep only the sections you need (e.g., Microsoft, Adobe) # Import the policy Set-AppLockerPolicy -XmlPolicy C:\Policies\AppLocker.xml -Merge
After importing, enforce the policy:
Set-ExecutionPolicy RemoteSigned -Scope Process -Force # optional for testing # Verify with Get-AppLockerPolicy -Effective | Out-String
Test the policy on a non‑critical workstation before rolling out domain‑wide; a mis‑configured rule can lock users out of essential tools.
Step 6: Set Up Regular, Immutable Backups
Backups are the final line of defense. Use Windows Server Backup or a third‑party solution that supports immutable (WORM) storage. Below is a PowerShell script that creates a daily VSS snapshot and copies it to a read‑only network share.
$src = "C:\" $dest = "\BackupServer\RansomwareProtected\$(Get-Date -Format yyyyMMdd)" # Create VSS snapshot $vss = (Get-WmiObject -List win32_shadowcopy).Create($src, "ClientAccessible") # Copy files (robocopy preserves attributes) robocopy $src $dest /MIR /R:3 /W:5 /COPYALL /XJ # Set share to read‑only icacls $dest /grant "Everyone:(R)" # Remove snapshot after copy $vss.Delete()
Schedule the script with Task Scheduler (run with highest privileges) and enable “Run whether user is logged on or not”. Store at least three generations of backups and keep one offline.
Step 7: Enforce Network‑Level Protections
Ransomware often spreads laterally via SMB. Harden SMB by enabling signing, disabling SMBv1, and restricting inbound file sharing.
# Disable SMBv1 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "SMB1" -Value 0 -Type DWord # Enforce SMB signing (client & server) Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" -Name "RequireSecuritySignature" -Value 1 -Type DWord Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "RequireSecuritySignature" -Value 1 -Type DWord # Block inbound SMB from untrusted subnets via Windows Firewall New-NetFirewallRule -DisplayName "Block SMB from Public" -Direction Inbound -Protocol TCP -LocalPort 445 -RemoteAddress "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" -Action Block
These settings force mutual authentication for every SMB transaction and prevent ransomware from exploiting legacy protocols.
Step 8: Deploy Advanced Auditing and Sysmon for Early Detection
Even a hardened system can be compromised. Deploy Sysinternals Sysmon with a ransomware‑focused configuration to capture process creation, file writes, and credential dumping.
# Install Sysmon (requires admin) sysmon -i -accepteula -n # Apply a minimal config (replace with your own XML) sysmon -c sysmon-ransomware.xml
Sample sysmon-ransomware.xml includes rules that flag:
- Renaming of multiple files in a short interval
- Execution of known ransomware payloads (hash‑based)
- Use of “vssadmin.exe Delete Shadows”
Forward Sysmon logs to a SIEM (e.g., Splunk, Azure Sentinel) and set alerts for the above patterns. Early detection buys you precious time to isolate the host.
Common Mistakes to Avoid
1. Turning off protection to “fix” a false positive. Instead, add a specific allow rule rather than disabling the whole feature.
2. Applying AppLocker rules without testing. A single missing DLL rule can render Outlook or Office unusable.
3. Storing backups on the same volume. Ransomware can encrypt local snapshots; always keep at least one copy offline.
4. Neglecting regular policy reviews. Threat landscapes shift; revisit ASR rules and baseline GPOs quarterly.
5. Using weak passwords for privileged accounts. Even with MFA, a compromised admin credential can bypass many controls.
Tips and Tricks
• Use Group Policy Preferences to push the same CFA and ASR settings across all domain computers—no manual PowerShell needed.
• Leverage Windows Defender Application Control (WDAC) for hardware‑rooted code integrity on high‑value servers.
• Combine Sysmon with PowerShell’s Get-WinEvent to build custom detection scripts that run locally when a SIEM is unavailable.
• Enable “Remote Credential Guard” on RDP sessions to stop credential theft that often precedes ransomware deployment.
• Periodically run Get-MpComputerStatus and Get-AppLockerPolicy to audit that your hardening measures remain active after Windows updates.
Frequently Asked Questions
Can I use these steps on Windows Home edition?
Most hardening features (CFA, ASR, PowerShell logging) are available on Home, but AppLocker and Group Policy Management require Pro or higher. For Home users, rely on third‑party application control tools and the built‑in Windows Defender settings.
Will enabling all ASR rules break my business applications?
Some legacy apps may be blocked, especially those that generate scripts on the fly or use unsigned macros. Start with the recommended baseline, monitor the ASR event log (Event ID 1122), and add allow rules for verified applications as needed.
How often should I rotate my backup media?
Adopt a 3‑2‑1 strategy: three generations of backups, stored on two different media types, with one copy off‑site. Rotate the off‑site copy weekly and test restoration quarterly to ensure integrity.
Conclusion
Ransomware is a moving target, but a disciplined, layered hardening approach dramatically reduces the odds of a successful infection. By enabling Controlled Folder Access, tightening Exploit Guard, locking down PowerShell, applying Microsoft’s security baselines, and coupling those defenses with immutable backups and proactive monitoring, you create a resilient Windows environment that can survive even sophisticated ransomware campaigns. Remember: security is a process, not a one‑time checklist—regularly audit, update, and test your controls to stay ahead of attackers.




