Reputation: 235
I have a simple .ps1 file:
$Server="remotepc.company.net"
$User=".\login"
$Password="password"
cmdkey /generic:TERMSRV/$Server /user:$User /pass:$Password
mstsc /v:$Server /h:1080 /w:1920
And anyway it asks for a password.
Upvotes: 1
Views: 9780
Reputation: 805
You could try:
$Server="remotepc.company.net"
$User="localhost\login"
$Password="password"
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
cmdkey /generic:$Server /user:$User /pass:$SecurePassword
mstsc /v:$Server /h:1080 /w:1920
Upvotes: 0
Reputation: 235
The issue was in $User=".\login"
.
login
is a local user name (not domain).
So to force it to work:
$User="localhost\login"
Upvotes: 1
Reputation: 9133
In RDP, go to the option checked to always ask for credentials:
Launch RDP → Show options → *un-check Always ask for credentials.
It seems, even though you gave credentials correctly, this was still making RDP ask.
Upvotes: 1