Run mstsc in PowerShell without a password prompt
我有一个简单的.ps1文件:
1 2 3 4 5 6 | $Server="remotepc.company.net" $User=".\\login" $Password="password" cmdkey /generic:TERMSRV/$Server /user:$User /pass:$Password mstsc /v:$Server /h:1080 /w:1920 |
而且无论如何它都会要求输入密码。
问题出在
因此强制其工作:
1 | $User="localhost\\login" |
在RDP中,转到选中的选项以始终要求提供凭据:
启动RDP→显示选项→*取消选中"始终要求提供凭据"。
看来,即使您正确提供了凭据,这仍然使RDP询问。
您可以尝试:
1 2 3 4 5 6 7 | $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 |