Security

Windows Server Security Best Practices: A Practical Checklist

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

A Windows server connected to the internet starts receiving login attempts within minutes, most of them automated scans against Remote Desktop. The good news is that the majority of successful attacks exploit a short list of weaknesses: missing patches, exposed RDP with weak passwords, unnecessary services and no tested backups. This checklist addresses each of them with concrete settings and PowerShell commands you can apply on Windows Server 2019, 2022 or later.

1. Patch first, then keep patching

Unpatched systems are the easiest target. Install all available updates before exposing the server, then keep a regular schedule.

  • Use Settings > Windows Update or sconfig on Server Core.
  • Configure an update and reboot window that suits your workload rather than postponing indefinitely.
  • Update the applications you install too: browsers, runtimes, database engines and control panels.

Check the last installed updates:

Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5

2. Lock down Remote Desktop

RDP is the most attacked service on Windows servers. Apply several layers:

  1. Restrict by IP. Allow port 3389 only from your office or home IP addresses in the cloud firewall. This single step removes nearly all automated attacks.
  2. Require Network Level Authentication (NLA), so users authenticate before a session is created:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1
  1. Use a VPN or RD Gateway when users connect from changing locations, instead of opening RDP to everyone.
  2. Limit who can log in. Only members of Administrators and Remote Desktop Users can connect by default. Keep the second group small.

Changing the RDP port reduces log noise but is not a security control on its own. Treat it as optional.

3. Harden accounts and passwords

  • Rename or disable the built-in Administrator after creating a named admin account. Attackers guess the default name first.
  • Use long passwords or passphrases of 14+ characters for every privileged account.
  • Enable an account lockout policy to slow down brute force:
net accounts /lockoutthreshold:5 /lockoutwindow:30 /lockoutduration:30

On domain-joined servers, set the same through Group Policy instead, because domain policy overrides local settings.

  • Separate daily and admin accounts. Do not browse the web or read email with an administrator session on the server.
  • On Active Directory, use Windows LAPS to give each server a unique, rotated local admin password.

4. Reduce the attack surface

Every installed role and running service is something that can be exploited. Review what is installed:

Get-WindowsFeature | Where-Object Installed | Select-Object Name
Get-Service | Where-Object Status -eq Running

Remove roles you do not use with Uninstall-WindowsFeature. Consider Server Core for new servers that do not need a desktop.

Disable SMBv1

SMBv1 is obsolete and was abused by major worms. Make sure it is off:

Get-SmbServerConfiguration | Select-Object EnableSMB1Protocol
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force

Also block port 445 from the internet. File sharing should only travel over a private network or VPN.

5. Configure the firewall properly

Keep Windows Defender Firewall enabled on all three profiles and combine it with the cloud firewall in front of the server:

Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True -DefaultInboundAction Block

Before setting the default action to block, confirm that an inbound rule allows your RDP connection, or you can lose remote access and need the browser console to recover.

Open only what the server actually serves:

ServicePortExposure
Website (IIS)80, 443Public
Remote Desktop3389Your IPs or VPN only
SMB file sharing445Private network only
SQL Server1433Application servers only
WinRM5985, 5986Admin IPs only

6. Keep Microsoft Defender active

Microsoft Defender Antivirus is built into Windows Server 2016 and later. Confirm it is running and its signatures are current:

Get-MpComputerStatus | Select-Object AMServiceEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated
Update-MpSignature

If an application vendor asks for exclusions, add only the specific folders or processes they document, never entire drives.

7. Enable auditing and watch the logs

Without logs you cannot tell whether an attack succeeded. At minimum, audit logon events and account changes:

auditpol /set /category:"Logon/Logoff" /success:enable /failure:enable
auditpol /set /category:"Account Management" /success:enable /failure:enable

Useful Security log event IDs:

  • 4625: failed logon, a spike indicates brute force.
  • 4624: successful logon, check logon type 10 for RDP.
  • 4720: user account created.
  • 4732: member added to a local security group.

Increase the Security log size so events are not overwritten within hours, and forward logs to a central system if you manage several servers.

8. Back up and test restores

Security includes recovering from what you could not prevent, such as ransomware. Follow the 3-2-1 idea: several copies, on different media, with one off the server. Combine VPS snapshots before risky changes with file-level or system state backups, and periodically restore something to prove the backup works. Our article on website backups explains how to plan retention.

9. Encrypt traffic

  • Use HTTPS with valid certificates for every website on IIS.
  • Disable legacy protocols such as SSL 3.0, TLS 1.0 and TLS 1.1 where your applications allow it.
  • Use encrypted connections for SQL Server and other remote services.

FAQ

Is changing the RDP port enough to protect my server?

No. It reduces the number of automated attempts in your logs, but scanners find services on any port. Restricting RDP by IP in the firewall, NLA, strong passwords and account lockout are the real protections.

Do I need third-party antivirus on Windows Server?

Not necessarily. Microsoft Defender Antivirus is included and adequate for many servers if it is kept enabled and updated. Some organizations add other tools for central management or advanced detection, which is a policy decision rather than a requirement.

How often should I review the server's security settings?

Review them after every significant change, such as a new role or application, and do a general review at least every quarter. Check failed logon events weekly, or set up alerts for them.

Related guides