我使用 winrm over SSL 在 Windows Azure 上创建了一个 Windows VM。
但是,我无法使用 powershell 脚本连接它。
当我运行以下命令时:
Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986
-Credential "hostname/username"
-SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
我收到询问密码的提示,输入密码后我设法连接。
但是,当我尝试自动化它时,它总是返回“访问被拒绝”
$securePassword = ConvertTo-SecureString -AsPlainText -Force "password"
$cred = New-Object System.Management.Automation.PSCredential "hostname/username", $securePassword
Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 -Credential $mycreds -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
有任何想法吗?
编辑
完整的错误如下所示:
Enter-PSSession:连接到远程服务器 myniceaspp.cloudapp.net 失败,并显示以下错误消息:访问被拒绝。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
在 line:1 char:1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
+ CategoryInfo : InvalidArgument: (https://myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed