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:

A Login You Do Not Recognise

  1. Check with quser whether the session is still open. logoff 3 ends the session with the ID 3.
  2. Change the password of Administrator and of your other users at once.
  3. Look for users you did not create: net user lists all accounts. More: Add a User Who Can Connect With Remote Desktop.
  4. 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

Was this answer helpful? 0 Users Found This Useful (0 Votes)