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.
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.
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.
The issue was in $User=".\login"
.
login
is a local user name (not domain).
So to force it to work:
$User="localhost\login"
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