Last active
February 19, 2024 11:05
-
-
Save jdforsythe/48a022ee22c8ec912b7e to your computer and use it in GitHub Desktop.
Remote Desktop Auto Login Powershell Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmdkey /list | ForEach-Object{if($_ -like "*target=TERMSRV/*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}} | |
echo "Connecting to 192.168.1.100" | |
$Server="192.168.1.100" | |
$User="Administrator" | |
$Password="AdminPassword" | |
cmdkey /generic:TERMSRV/$Server /user:$User /pass:$Password | |
mstsc /v:$Server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://technet.microsoft.com/library/hh847748.aspx | |
# Run PowerShell as Administrator | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nolog -command cmdkey /generic:TERMSRC/some_unc_path /user:username /pass:pa$$word; mstsc /v:some_unc_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmdkey /list | ForEach-Object{if($_ -like "*target=TERMSRV/*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}} | |
echo "Connecting to somethingspecial.cloudapp.net" | |
$Server="somethingspecial.cloudapp.net" | |
$Port="49982" | |
$User="Administrator" | |
$Password="AdminPassword" | |
cmdkey /add:$Server /user:$User /pass:$Password | |
mstsc /v:$Server:$Port |
connect.ps1, is failing to load the password to mstsc, hence not bein ale to login, can someone please suggest anything?
Hello,
I'm actually facing the same issue. i used the code as above. The script is launching an RDP but unable to enter the password in it. Can you let me know how you fixed this issue?
I think the key from @gyanu89's code is that you need to wipe the old credentials from cmdkey first, so try adding this line to the beginning of the script:
cmdkey /list | ForEach-Object{if($_ -like "*target=TERMSRV/*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}}
cmdkey /generic:IP_PUBLIC /user:DOMAIN\USER /pass:"PASS"
mstsc.exe /v: IP_PUBLIC
exit
what if i want to start another ps script located in the remote server in which Iogged in with this script ? can anyone please support.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can try here u may save ur current id password in ps file and call same file again and again only server name need to enter.
https://github.com/gyanu89/AutomatedRDP_Script