【问题标题】:"Access denied" on Remote winrm [closed]远程winrm上的“访问被拒绝”[关闭]
【发布时间】:2014-03-27 06:48:34
【问题描述】:

我在 Windows Azure 上创建了一个 Windows VM,并设置了 winrm over SSL。

但是,我无法使用 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

【问题讨论】:

  • 可能是您使用的用户是机器管理员而不是域管理员的情况。
  • @Aravind 是不是意味着我也不能使用提示进行连接?
  • 嗯。这就是我遇到这个问题的场景。取决于此 VM 是否是域 (AD) 的一部分。如果只是一台虚拟机,则上述情况不适用。我有这个工作michaelwasham.com/windows-azure-powershell-reference-guide/…
  • 一方面,您在使用$cred$mycreds 之间切换——这是行不通的。 -- 但你的语法也是错误的 -- 应该是这样的:$securePassword = ("securePassword" | ConvertTo-SecureString -AsPlainText -Force); 然后下一行到$mycreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "userName", $securePassword;

标签: powershell azure powershell-remoting winrm


【解决方案1】:

最近有类似的问题。建议您仔细检查您正在连接的用户是否在远程计算机上具有适当的授权。

您可以使用以下命令查看权限。

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell

在这里找到这个提示:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/17/configure-remote-security-settings-for-windows-powershell.aspx

它为我修好了。

【讨论】:

  • 这是我们在使用显式 AD 组(例如“mydomain\Server Admins”)获得服务器管理员权限时遇到的相同问题。唯一的解决方法是显式添加用户到Microsoft.Powershell PS 会话配置。另一种解决方法是使用户成为明确的本地管理员。当使用组继承时,PSSession 似乎不会一直遍历用户组。
猜你喜欢
  • 2014-12-26
  • 2013-05-07
  • 2017-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-19
相关资源
最近更新 更多