Few days back I was asked to create a script, which will check RDP port status of multiple servers and send the result as an email notification. I have searched for few, but unfortunately there was no ready script for that. I decided to build one using PowerShell, and came out with following script.
Hope this script might help you as well.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#Which port to scan $port = 3389 #Path of the input server list $hostns=Get-Content D:Servers.txt $body = @() foreach ($hostn in $hostns) { $PortCon = new-object System.Net.Sockets.TcpClient($hostn, $port) if ($PortCon.Connected -eq 'True') { $body +="$hostn Server listening to port $port" $PortCon.Close() } else { $body +="$hostn Server not responding to $port" } } $body = $body | Out-String $NotiEmail = @{ Subject = "Server Status Check" SMTPServer = "YOUR SMTP SERVER" Priority = "High" Body = $body } Send-MailMessage @NotiEmail |
Β
RedSun: New Microsoft Defender Zero-Day Lets Unprivileged Users Gain SYSTEM Access
A freshly disclosed zero-day vulnerability in Microsoft Defender, dubbed "RedSun," has raisedβ¦
Researcher Publishes Windows Defender 0-Day βBlueHammerβ LPE ProofβofβConcept
A security researcher using the handle Chaotic Eclipse has publicly released aβ¦
Recently Leaked Windows Zero-Days Now Being Actively Exploited: What You Need to Know
Threat actors have begun abusing three recently disclosed Windows vulnerabilities to escalateβ¦
One-Click RCE in Azure Windows Admin Center: what happened and what you need to do
Windows Admin Center (WAC) is a convenient, browser-based management hub for administratorsβ¦