powershell - 远程 winrm 上的 "Access denied"

标签 powershell azure powershell-remoting winrm

我在 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 : Connecting to remote server myniceaspp.cloudapp.net failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.

At line:1 char:1
+ Enter-PSSession -ConnectionUri https://myniceaspp.cloudapp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https:// myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

最佳答案

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

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

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell

在这里找到这个提示:

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

它为我解决了这个问题。

关于powershell - 远程 winrm 上的 "Access denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22680211/

相关文章:

powershell - 传递远程 Powershell 变量

django - 如何从 celery-django 项目安全连接到 Azure redis?

azure - 将 Azure 存储中的 Azure 自动化帐户列入白名单,以便从 blob 读取压缩模块并上传到 azure 自动化模块中

azure - Docker 永远不会在 Azure 上运行 - 等待对容器预热请求的响应

powershell - 使用 get-childItem 进行 PSRemoting 性能开销

powershell - 在 powershell 中执行 Enter-PSSession 时出现随机错误

powershell - 拥有 MFA 时使用 Windows Powershell ISE for Exchange

powershell - 基于时间的while循环

powershell - PowerShell-为什么在哈希表中查找数组会返回一个空数组?

powershell - 在 PowerShell 脚本中创建/销毁新环境