Every Windows server with Remote Desktop open to the Internet is found by automatic programs within hours, and from then on they try usernames and passwords all day. That is normal, and it is harmless as long as nobody gets in. This guide shows how to see who is logged in now, who connected before, how many attempts failed and what to do about it.
The examples use Windows Server 2025. Run the commands in PowerShell as Administrator: right-click the Start button and choose Terminal (Admin).
1. Who Is Logged In Right Now
quser
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME >administrator rdp-tcp#14 2 Active . 12/1/2026 5:18 PM
Each line is one session. The line with > is your own. You should recognise every other line.
2. Remote Desktop Logins
Windows keeps a small log of every Remote Desktop session, with the user and the address it came from. This shows the last 20 entries:
Get-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" -FilterXPath "*[System[(EventID=21 or EventID=25)]]" -MaxEvents 20 | Select-Object TimeCreated, Id, @{n="User";e={$_.Properties[0].Value}}, @{n="Address";e={$_.Properties[2].Value}} | Format-Table -AutoSize
TimeCreated Id User Address ----------- -- ---- ------- 12/1/2026 7:29:37 PM 25 SERVER01\Administrator 203.0.113.25 12/1/2026 5:18:04 PM 21 SERVER01\Administrator 203.0.113.25 12/1/2026 3:44:27 PM 21 SERVER01\Administrator 203.0.113.25
Id 21 is a new login, Id 25 a return to a session that was still open. A login from an address you do not know, at a time when you were not working, is the thing to look for. This log is small and reaches back weeks or months.
3. Failed Attempts
Failed logins are in the Security log as event 4625. Load the ones of the last 24 hours into a variable, or as many as the log still holds (step 4). On a busy server this takes a few minutes:
$f = Get-WinEvent -FilterHashtable @{LogName="Security"; Id=4625; StartTime=(Get-Date).AddDays(-1)}
$f.Count
33680
A number in the thousands is usual for a server with a public address. Which addresses try the most:
$f | ForEach-Object { $_.Properties[19].Value } | Group-Object | Sort-Object Count -Descending | Select-Object -First 5 Count, Name
Count Name ----- ---- 16187 198.51.100.50 15985 198.51.100.49 203 198.51.100.122
And which usernames they try:
$f | ForEach-Object { $_.Properties[5].Value } | Group-Object | Sort-Object Count -Descending | Select-Object -First 5 Count, Name
Count Name ----- ---- 17496 administrator 16136 admin 36 user
4. Keep the Security Log Longer
The Security log has a fixed size of 20 MB, and old events are overwritten. With thousands of failed attempts per hour it holds only the last few hours. See how far back it reaches:
(Get-WinEvent -LogName Security -MaxEvents 1 -Oldest).TimeCreated
To keep about ten times as much, raise the size to 200 MB:
wevtutil sl Security /ms:209715200
The log of step 2 is not affected by this: it is separate and fills slowly.
5. What to Do
Many Failed Attempts
You cannot stop strangers from trying, but you can make sure that trying is useless:
- Allow Remote Desktop only from your own addresses. Then strangers cannot even reach the login: Allow Remote Desktop Only From Your IP Addresses.
- Use a long password that is used nowhere else: How to Change the Administrator Password on Windows Server.
- Know the lockout. After too many wrong passwords Windows blocks the account for a while, also for you: Remote Desktop Says the Account Is Locked.
- Keep Windows up to date: Windows Update on Windows Server.
A Login You Do Not Recognise
- Check with
quserwhether the session is still open.logoff 3ends the session with the ID 3. - Change the password of Administrator and of your other users at once.
- Look for users you did not create:
net userlists all accounts. More: Add a User Who Can Connect With Remote Desktop. - If the stranger was logged in as an administrator, you cannot know what was changed. The safe way is to save your data and reinstall the server.
Good to Know
- The same events in a window: open Event Viewer from the Start menu. The Remote Desktop log of step 2 is under Applications and Services Logs > Microsoft > Windows > TerminalServices-LocalSessionManager > Operational, the failed logins of step 3 under Windows Logs > Security.
- The times are times of the server. A new server may run on UTC: Set the Time Zone on Windows Server and Check That the Clock Is Right.
- First steps on a new server: Windows Server: Quick Start Guide.