1

Found the Microsoft document . but it ask for user prompt.

so is there any way to Rdp without user credentials(without user prompts) ?

Leo Liu
  • 71,098
  • 10
  • 114
  • 135

1 Answers1

0

If you have the IP, you can do in Powershell:

$rdpIp = "dottedIP.or.DNSName.of.VM"

cmdkey /generic:TERMSRV/$rdpIp /user:username /pass:"password"
mstsc /v:$rdpIp
cmdkey /delete:TERMSRV/$rdpIp

Going a step further, if you install Powershell Secrets Management (and configure a secret store as documented), you can set up a credential as follows:

#isolate your username and password from the connection script itself
Set-Secret -Name MyRDPUserName -Secret "MyUserNameValue"
Set-Secret -Name MyRDPPassword -Secret "MyPasswordValue"

and then the script to connect looks like:

$rdpIp = "dottedIP.or.DNSName.of.VM"
#get the secrets from the store
$user = Get-Secret -Name MyRDPUserName -AsPlainText
$pass = Get-Secret -Name MyRDPPassword -AsPlainText

cmdkey /generic:TERMSRV/$rdpIp /user:"$user" /pass:"$pass"
#erase the values from your Powershell session
$user = $null
$pass = $null

mstsc /v:$rdpIp

#remove the stored credential
cmdkey /delete:TERMSRV/$rdpIp
WaitingForGuacamole
  • 3,744
  • 1
  • 8
  • 22