I'm tasked with testing multiple RDP connections weekly, which involves logging in with incorrect credentials a few times to ensure that our RDP security software effectively blocks my IP address. While ideally, these machines would be on a VPN, it's not always feasible for various reasons. I can confirm if the port is open using Test-NetConnection, but I'm looking for a way to automate the login attempts through scripting. I've done some research but haven't found any viable solutions. Any guidance would be appreciated! Thanks!
5 Answers
I haven't found a native PowerShell solution, but in the past, I used this method:
```
cmdkey /generic:"server-address" /user:"username" /pass:"password"
mstsc /v:server-address
cmdkey /delete:server-address
```
Make sure you check the command's exit code to determine if you failed to connect. Just make sure the remote server allows saved credentials!
I thought there were various hacking tools or Linux options for this, but I don't know of a PowerShell method. Other than mstsc, there are tools like RCman, Royal TS, or mRemoteNG that can manage your connections and might help.
Are you not already seeing a lot of failed login attempts with it exposed like this?
Yes, you can definitely script the use of mstsc.exe! It's a viable approach.
Check out my `invoke-mstsc` function on GitHub! It's designed exactly for what you need. Here’s the link: https://github.com/ztrhgf/LAPS
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String