Winserver
LIMITED-TIME OFFER Nov 16, 2026 – Jan 15, 2027
Windows VPS: double your plan, up to 6 months free!
On SSD-2GB to SSD-8GB plans, hosted in Japan. Applied automatically at checkout.
See details →
MENU
  • Blog Home
  • Categories
    • DMM & Browser Gaming
    • Business in Japan
    • Development
    • Forex Trading
    • Security
    • Windows Server/VPS Guides
  • Winserver VPS Japan
Windows VPS starting from $9.90
Providing reliable Windows VPS services from Japan since 2004.
Winserver Blog
  • Blog Home
  • Categories
    • DMM & Browser Gaming
    • Business in Japan
    • Development
    • Forex Trading
    • Security
    • Windows Server/VPS Guides
  • Winserver VPS Japan
Winserver Blog
  • Blog Home
  • Categories
    • DMM & Browser Gaming
    • Business in Japan
    • Development
    • Forex Trading
    • Security
    • Windows Server/VPS Guides
  • Winserver VPS Japan
  1. Home
  2. Security
  3. How to Stop RDP Brute-Force Attacks on a Windows VPS (2026 Guide)

How to Stop RDP Brute-Force Attacks on a Windows VPS (2026 Guide)

2026 11/25
Security
2026-11-25
Blocking RDP brute-force attacks on a Windows VPS with PowerShell and Windows Firewall

Last updated: November 19, 2026

If your Windows VPS has Remote Desktop open to the internet, it’s almost certainly being attacked right now. Automated bots scan the internet for Remote Desktop (RDP) on port 3389 and try thousands of user names and passwords, day and night. Security researchers recently reported one campaign using more than 30,000 new IP addresses every day to target RDP, and exposed RDP remains one of the most common ways attackers break into servers.

The good news: brute-force attacks only work against weak defenses. This guide shows you how to see the attacks on your own server, then shut them out step by step, with copy-paste PowerShell scripts for each stage.

Quick answer

  • Check: look for failed sign-ins (event ID 4625) to see who’s attacking your server.
  • Basics: use a long, unique password, rename the built-in Administrator account, turn on account lockout and keep Network Level Authentication (NLA) on.
  • Best protection: only allow Remote Desktop from your own IP address, or connect through a VPN, so bots can’t reach the sign-in screen at all.
  • Extra: automatically block IP addresses that fail to sign in too many times.
TABLE OF CONTENTS

How RDP Brute-Force Attacks Work

A brute-force attack is simply guessing, at scale:

  1. Scanning: bots constantly scan the internet for servers answering on the Remote Desktop port.
  2. Guessing: they try common user names, especially Administrator, admin and user, with lists of leaked and common passwords.
  3. Getting in: once a guess works, the attacker has full control of the server. Compromised servers are often used for ransomware, sending spam, mining cryptocurrency or attacking other systems.

Attackers use huge numbers of different IP addresses, so blocking addresses one by one isn’t enough on its own. The real defense is making sure a guess can’t succeed, and ideally that bots can’t reach the sign-in screen at all.

Prefer to download the scripts? rdp-security-scripts.zip, which contains all three scripts from this guide. The full code is also shown below, so you can read what each one does before running it.

Step 1: See Whether Your Server Is Being Attacked

Every failed sign-in is recorded in the Windows Security log as event ID 4625. This script reads the last 24 hours and shows how many attempts there were, which IP addresses they came from, which user names were tried, and your current security settings. It changes nothing.

Run it in Windows PowerShell as Administrator:

# RDP security check for a Windows VPS. Changes nothing.
# Run in Windows PowerShell as Administrator.
 
"=== Failed sign-in attempts in the last 24 hours ==="
$fails = Get-WinEvent -FilterHashtable @{ LogName = "Security"; Id = 4625; StartTime = (Get-Date).AddHours(-24) } -ErrorAction SilentlyContinue
"Total failed sign-ins: $(@($fails).Count)"
$fails | ForEach-Object {
    $d = ([xml]$_.ToXml()).Event.EventData.Data
    [pscustomobject]@{
        IP   = ($d | Where-Object Name -eq "IpAddress").'#text'
        User = ($d | Where-Object Name -eq "TargetUserName").'#text'
    }
} | Group-Object IP | Sort-Object Count -Descending | Select-Object -First 10 Count, @{ n = "IP address"; e = { $_.Name } } | Format-Table -AutoSize
 
"=== User names attackers tried most ==="
$fails | ForEach-Object { (([xml]$_.ToXml()).Event.EventData.Data | Where-Object Name -eq "TargetUserName").'#text' } |
    Group-Object | Sort-Object Count -Descending | Select-Object -First 5 Count, Name | Format-Table -AutoSize
 
"=== Account lockout policy ==="
net accounts
 
"=== Built-in Administrator account ==="
$admin = Get-LocalUser | Where-Object { $_.SID -like "S-1-5-*-500" }
"Name: $($admin.Name)   Enabled: $($admin.Enabled)"
if ($admin.Name -eq "Administrator") { "Tip: attackers guess 'Administrator' first. Consider renaming it." }
 
"=== Network Level Authentication (NLA) ==="
$ts = Get-CimInstance -Namespace root\cimv2\terminalservices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'"
if ($ts.UserAuthenticationRequired -eq 1) { "NLA is ON" } else { "NLA is OFF: turn it on" }
 
"=== Remote Desktop port and firewall ==="
$port = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp").PortNumber
"RDP port: $port"
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -contains "$port" } | Get-NetFirewallRule |
    Where-Object { $_.Direction -eq "Inbound" -and $_.Enabled -eq "True" -and $_.Action -eq "Allow" } |
    ForEach-Object { [pscustomobject]@{ Rule = $_.DisplayName; "Allowed from" = ($_ | Get-NetFirewallAddressFilter).RemoteAddress -join ", " } } |
    Format-Table -AutoSize
 
"=== Your current Remote Desktop connection comes from ==="
(Get-NetTCPConnection -LocalPort $port -State Established -ErrorAction SilentlyContinue).RemoteAddress | Sort-Object -Unique

What to look for:

  • Hundreds or thousands of failed sign-ins mean bots have found your server. This is common and doesn’t mean they got in, but it’s a clear sign to harden it.
  • The user names tried show what attackers are guessing. If your own user name appears often, change it.
  • The last line shows the IP address you’re connecting from right now. You’ll need it in Step 5.

If the IP column shows - for some entries, Windows couldn’t record the address for those attempts. The count is still accurate.

No failed sign-ins at all? Check that failure auditing is on:

auditpol /get /subcategory:"{0CCE9215-69AE-11D9-BED3-505054503030}"

If it doesn’t show Failure, turn it on with:

auditpol /set /subcategory:"{0CCE9215-69AE-11D9-BED3-505054503030}" /failure:enable

The long code is the ID of the “Logon” audit category, which works on any Windows language, including Japanese.

Step 2: Use a Strong Password and Rename Administrator

Use a long, unique password. A password of 16 or more random characters, stored in a password manager, can’t realistically be guessed. Short passwords, or ones reused from other sites, are what brute-force attacks rely on.

Rename the built-in Administrator account. Attackers guess Administrator first, so a different name means they have to guess both the user name and the password:

Rename-LocalUser -Name "Administrator" -NewName "your-new-name"

Before you close your current session, open a new Remote Desktop connection and sign in with the new name to check it works. Your password stays the same.

Set a minimum password length for any other accounts on the server:

net accounts /minpwlen:14

Step 3: Turn On Account Lockout

Account lockout temporarily blocks an account after too many wrong passwords, which stops guessing in its tracks. For example, lock an account for 30 minutes after 10 failed attempts:

net accounts /lockoutthreshold:10 /lockoutduration:30 /lockoutwindow:30

A trade-off to know about: attackers who guess your user name can lock your account on purpose, so you can’t sign in for a while. That’s another reason to rename Administrator in Step 2. On some Windows versions, the built-in Administrator account isn’t covered by lockout at all, so a strong password and a different name matter even more for it.

Step 4: Keep Network Level Authentication On

Network Level Authentication (NLA) makes users sign in before a full Remote Desktop session starts. This saves server resources during attacks and blocks some attack types completely. It’s usually on by default. The Step 1 script tells you; if it’s off, turn it on:

Get-CimInstance -Namespace root\cimv2\terminalservices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'" |
  Invoke-CimMethod -MethodName SetUserAuthenticationRequired -Arguments @{ UserAuthenticationRequired = 1 }

Step 5: Only Allow Remote Desktop from Your IP Address

This is the most effective step: if Windows Firewall only accepts Remote Desktop from your own IP address, bots can’t even reach the sign-in screen, and the failed sign-ins in Step 1 drop to almost zero.

Find your IP address: the last line of the Step 1 script shows it, or search “what is my IP” on your own computer. This works best if your internet connection has a fixed IP address. If your address changes often, use a VPN instead (Step 6).

Because a mistake here could lock you out, this script has a safety net: it schedules an automatic undo in 10 minutes. You test a new connection, and only if it works do you cancel the undo. Change the IP address at the top, then run it:

# Allows Remote Desktop only from the IP addresses you list.
# Includes a safety net: the change is undone automatically after 10 minutes
# unless you confirm it. Run in Windows PowerShell as Administrator.
 
# Your own IP address(es). Separate several with commas: "203.0.113.10", "198.51.100.25"
$AllowedIPs = @("203.0.113.10")
 
$port = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp").PortNumber
 
# 1. Safety net: a scheduled task that reopens RDP to everyone in 10 minutes
$undo = "Get-NetFirewallPortFilter | Where-Object { `$_.LocalPort -contains '$port' } | Get-NetFirewallRule | Where-Object Direction -eq 'Inbound' | Set-NetFirewallRule -RemoteAddress Any"
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($undo))
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -EncodedCommand $encoded"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(10)
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
Register-ScheduledTask -TaskName "Undo RDP IP limit" -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null
 
# 2. Limit the Remote Desktop firewall rules to your IP address(es)
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -contains "$port" } | Get-NetFirewallRule |
    Where-Object { $_.Direction -eq "Inbound" -and $_.Action -eq "Allow" } |
    Set-NetFirewallRule -RemoteAddress $AllowedIPs
 
"Remote Desktop now only accepts connections from: $($AllowedIPs -join ', ')"
""
"NOW: open a NEW Remote Desktop connection to this server to test it."
"If it works, confirm the change with:"
"    Unregister-ScheduledTask -TaskName 'Undo RDP IP limit' -Confirm:`$false"
"If you do nothing, the limit is removed automatically in 10 minutes."

To add another IP address later (for example, your office), run the script again with all of your addresses in $AllowedIPs.

To remove the limit and allow Remote Desktop from anywhere again:

$port = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp").PortNumber
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -contains "$port" } | Get-NetFirewallRule |
  Where-Object { $_.Direction -eq "Inbound" -and $_.Action -eq "Allow" } | Set-NetFirewallRule -RemoteAddress Any

If you ever get locked out (for example, your home IP address changes), [CONFIRM: use the console in your VPS control panel or contact support] to remove the limit. For more on firewall rules, see how to configure firewall rules on a Windows VPS without breaking remote access.

SECURE WINDOWS VPS IN JAPAN

Keep Remote Desktop off the open internet

The safest Remote Desktop is one bots can’t reach. Winserver plans from SSD-4G up include SoftEther VPN, so you can connect through your own private VPN and limit Remote Desktop to it. Every plan comes with Windows Server, the license included and full administrator access to lock down your server your way.

See Windows VPS Plans →

Recommended: 4 GB plan with VPN from $19.80/month · Windows license included · No setup fees

Step 6: Connect Through a VPN Instead

If your IP address changes, or you connect from many places, a VPN gives the same protection: you connect to the VPN first, then use Remote Desktop through it, and Remote Desktop only accepts connections that come through the VPN.

Winserver plans from SSD-4G up include SoftEther VPN, so you can use your own VPS as a private VPN server. Once the VPN is working, run the Step 5 script with your VPN’s address range in $AllowedIPs (for example, "192.168.30.0/24"; use the range your VPN actually assigns).

See how to set up SoftEther VPN Client on Windows.

Step 7 (Optional): Automatically Block Attackers

If Remote Desktop must stay open to the internet, this script blocks any IP address with 10 or more failed sign-ins in the last hour. It adds them to a single firewall block rule and logs what it blocked. Your own IP addresses are never blocked.

Create the folder and the script file:

New-Item -ItemType Directory -Force -Path C:\Scripts
notepad C:\Scripts\block-rdp-attackers.ps1

Paste the following, change $NeverBlock to your own IP address, and save:

# Blocks IP addresses with too many failed sign-ins in the last hour.
# Save as C:\Scripts\block-rdp-attackers.ps1 and run every 15 minutes (see the article).
 
$Threshold = 10                         # failed sign-ins per hour before blocking
$NeverBlock = @("203.0.113.10")         # your own IP addresses: never blocked
$RuleName = "Block RDP brute-force IPs"
$LogFile = "C:\Scripts\blocked-ips.log"
 
$attackers = Get-WinEvent -FilterHashtable @{ LogName = "Security"; Id = 4625; StartTime = (Get-Date).AddHours(-1) } -ErrorAction SilentlyContinue |
    ForEach-Object { (([xml]$_.ToXml()).Event.EventData.Data | Where-Object Name -eq "IpAddress").'#text' } |
    Where-Object { $_ -and $_ -ne "-" -and $_ -notin $NeverBlock -and $_ -notmatch "^(127\.|::1$|10\.|192\.168\.)" } |
    Group-Object | Where-Object Count -ge $Threshold | ForEach-Object Name
 
if (-not $attackers) { return }
 
$rule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
if ($rule) {
    $current = @(($rule | Get-NetFirewallAddressFilter).RemoteAddress) | Where-Object { $_ -ne "Any" }
    $new = @($attackers | Where-Object { $_ -notin $current })
    if ($new.Count -eq 0) { return }
    Set-NetFirewallRule -DisplayName $RuleName -RemoteAddress (@($current) + $new)
} else {
    $new = @($attackers)
    New-NetFirewallRule -DisplayName $RuleName -Direction Inbound -Action Block -RemoteAddress $new | Out-Null
}
 
Add-Content -Path $LogFile -Value "$(Get-Date -Format 'yyyy-MM-dd HH:mm') blocked: $($new -join ', ')"

Then run it automatically every 15 minutes:

$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\block-rdp-attackers.ps1"
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 15)
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
Register-ScheduledTask -TaskName "Block RDP attackers" -Action $action -Trigger $trigger -Principal $principal

Check what’s been blocked:

Get-Content C:\Scripts\blocked-ips.log -Tail 20

Unblock everything (for example, if you blocked yourself by mistake):

Remove-NetFirewallRule -DisplayName "Block RDP brute-force IPs"

Keep expectations realistic: large botnets rotate through thousands of addresses, so this reduces the noise rather than stopping attacks completely. It works best alongside Steps 2 to 4, and isn’t needed if you’ve done Step 5 or 6.

What About Changing the RDP Port?

Moving Remote Desktop from port 3389 to another port reduces the number of automated attempts, because many bots only scan the default port. But it isn’t real protection: scanners that check every port will still find it. If you change it, open the new port in the firewall before changing it, and keep the other steps in this guide in place. Limiting access to your IP address (Step 5) or a VPN (Step 6) is far more effective.

Keep Windows Updated

Strong passwords don’t help against flaws in Remote Desktop itself, and several Remote Desktop vulnerabilities have been patched this year. Install Windows security updates regularly, and set active hours so restarts don’t interrupt your work.

Troubleshooting

Problem Likely cause Fix
“The referenced account is currently locked out” Too many wrong passwords, by you or an attacker Wait for the lockout time to pass (30 minutes in Step 3), then sign in. If it keeps happening, rename the account (Step 2) and limit RDP to your IP (Step 5).
Can’t connect after Step 5 The IP address in the script isn’t the one you connect from Wait 10 minutes for the automatic undo, check your IP address, and run the script again.
Could connect, then stopped working days later Your home or office IP address changed Use your provider’s console or support to remove the limit, then consider a VPN (Step 6).
Step 1 shows no failed sign-ins Failure auditing is off, or RDP is already limited Check auditing with the auditpol command in Step 1.
IP address shows as - Windows couldn’t record the address for that attempt Normal for some attempts. The block script skips these.
Blocked yourself with the Step 7 script Your IP address wasn’t in $NeverBlock Connect from another network or use your provider’s console, run Remove-NetFirewallRule -DisplayName "Block RDP brute-force IPs", then add your address.
Scripts won’t run (“running scripts is disabled”) PowerShell’s execution policy Paste the code straight into PowerShell or run the file with powershell -ExecutionPolicy Bypass -File script.ps1.

RDP Security Checklist

  • Failed sign-ins checked (Step 1)
  • Long, unique password stored in a password manager
  • Built-in Administrator account renamed
  • Account lockout turned on
  • Network Level Authentication on
  • Remote Desktop limited to your IP address, or reached only through a VPN
  • Optional: automatic blocking of repeat offenders
  • Windows security updates installed regularly

FAQ

Q1. How do I know if someone is trying to break into my VPS?

Look for event ID 4625 (failed sign-in) in the Windows Security log. The Step 1 script counts them and shows which IP addresses and usernames were used. Hundreds of failed attempts a day are common on servers with Remote Desktop open to the internet.

Q2. Do failed sign-ins mean my server was hacked?

No. They mean bots tried and failed. To check for a successful break-in, look for successful sign-ins (event ID 4624) from IP addresses you don’t recognize, and for user accounts you didn’t create.

Q3. What’s the single most effective step?

Only allowing Remote Desktop from your own IP address (Step 5), or only through a VPN (Step 6). Bots can’t attack a sign-in screen they can’t reach.

Q4. Is changing the RDP port enough?

No. It reduces automated attempts, but scanners that check every port will still find Remote Desktop. Use it only alongside strong passwords, lockout and IP limits.

Q5. Will account lockout lock me out?

It can, if attackers guess your username. That’s why renaming the Administrator account matters. Lockout is temporary, and you can sign in again after the lockout time passes.

Q6. Is there a tool that blocks attackers automatically, like fail2ban on Linux?

Windows doesn’t include one, but the Step 7 script does the same basic job. Free third-party tools also exist, if you want more features.

Q7. Is it safer to use a VPN than open RDP?

Yes. With a VPN, Remote Desktop isn’t visible to the internet at all. Winserver plans from SSD-4G up include SoftEther VPN for this.

Sources: Huntress: Exposed RDP, the misconfiguration that keeps paying off; Rewterz: campaign using over 30,000 new IP addresses daily against RDP; Microsoft Learn: Event 4625: An account failed to log on

A Windows VPS with Built-In VPN

Winserver’s Windows VPS plans include the Windows Server license and full administrator access, and plans from SSD-4G up include SoftEther VPN, so you can keep Remote Desktop off the open internet. English support is included.

View Windows VPS Plans
Security
Brute Force Firewall PowerShell RDP remote desktop Security VPN Windows Server windows vps
  • How to Host a .NET 11 App on IIS (Windows Server 2026): with PowerShell
  • Microsoft's Code Red and the "Patchpocalypse": How to Use AI to Stay Ahead of Windows Server Updates

Browse by Category

  • Business in Japan
  • Development
  • DMM & Browser Gaming
  • Forex Trading
  • Security
  • Windows Server/VPS Guides

Browse by Month

Your subscription could not be saved. Please try again.
Your subscription has been successful!

New Guides,

Straight to Your Inbox!

Join our newsletter for the latest articles, VPS tips, and updates!

Winserver.net

Windows VPS starting from $9.90/mon



View Plans Winserver.net on ServerVerify

© Winserver All Rights Reserved.

TABLE OF CONTENTS

Winserver Blog

Security