I'm looking for a way to automate my weekly RDP connection tests. Right now, I manually log into several RDP connections, intentionally entering the wrong username and password to trigger our security software, which blocks my IP. Ideally, I want to know if there's a way to script this login process using PowerShell or any other method, as simple connectivity tests don't seem sufficient. I know VPNs would solve a lot of problems, but they're not feasible in my situation. Any insights would be greatly appreciated!
6 Answers
You might want to check out this GitHub link that has a script for invoking mstsc, which could be exactly what you need! Here’s the URL: https://github.com/ztrhgf/LAPS
I’ve heard that tools like RCman, Royal TS, or mRemoteNG may help streamline your connections without needing to rely on PowerShell. They allow saving connections, which could be useful for your testing.
I don’t know a native PowerShell solution, but I’ve used this workaround:
cmdkey /generic:"server-address" /user:"username" /pass:"password"
mstsc /v:server-address
cmdkey /delete:server-address
The key is to check the result from the mstsc command - if it’s non-zero, then the connection failed.
Are you already seeing a lot of failed login attempts with your current setup? If so, it might be worth considering the security implications.
If VPN isn't an option, consider implementing an RDP Proxy or a third-party gateway like NetScaler to enhance security. As for scripting your tests, I've found that many suggested solutions rely on credentials being cached, which might not work if that's disabled in your setup.
Yes, you can script mstsc.exe itself to automate these tests. Just make sure your remote server allows logins with saved credentials!
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
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