问题描述
我在Windows Azure上创建了Windows VM,并通过SSL设置了winrm.
I created a Windows VM on Windows Azure with winrm over SSL set.
但是,我无法使用Powershell脚本进行连接.
But, I can't connect it using a powershell script.
运行以下命令时:
Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986
-Credential "hostname/username"
-SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
我收到提示要求输入密码的提示,输入密码后,我就可以连接了.
I'm getting a prompt asking for password and after I type it I manage to connect.
但是,当我尝试使其自动化时,它总是返回访问被拒绝"
But, when I try to automate it, it always returns with "Access is denied"
$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)
有什么想法吗?
修改
完整错误如下:
第1行char:1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:InvalidArgument:(https://myniceaspp ... udapp.net:5986/:Uri)[Enter-PSSession],PSRemotingTransportException
+ FullyQualifiedErrorId:CreateRemoteRunspaceFailed
At line:1 char:1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https:// myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
推荐答案
最近有类似的问题.建议您仔细检查与您连接的用户在远程计算机上是否具有正确的授权.
Had similar problems recently. Would suggest you carefully check if the user you're connecting with has proper authorizations on the remote machine.
您可以使用以下命令查看权限.
You can review permissions using the following command.
Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell
在此处找到此提示:
它为我修复了.
这篇关于“访问被拒绝";在远程winrm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!