【问题标题】:Enter-PSSession returns PSInvalidOperationExceptionEnter-PSSession 返回 PSInvalidOperationException
【发布时间】:2017-10-12 09:55:31
【问题描述】:

我正在尝试使用:

Enter-PSSession -ComputerName 10.10.10.5 -Credential administrator

这给了我:

Enter-PSSession : MI_RESULT_ACCESS_DENIED
At line:1 char:1
+ Enter-PSSession -ComputerName 10.10.10.5 -Credential administrator ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (10.10.10.5:String) [Enter-PSSession], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Ansible 同时工作没有问题:

Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/setup.ps1
<10.10.10.5> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.10.10.5
<10.10.10.5> WINRM CONNECT: transport=ssl endpoint=https://10.10.10:5986/wsman
<10.10.10.5> WINRM OPEN SHELL: 5001549B-C9A9-41FF-B9A3-8D19155EE123
EXEC (via pipeline wrapper)
<10.10.10.5> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-']
<10.10.10.5> WINRM RESULT u'<Response code 1, out "{"changed":false,"an", err "\r\n">'
<10.10.10.5> WINRM CLOSE SHELL: 5001549B-C9A9-41FF-B9A3-8D19155EE123

有什么方法可以调试吗?

【问题讨论】:

  • -ComputerName 正在寻找一个字符串。试试 Enter-PSSession -ComputerName '10.10.10.5' -Credential administrator

标签: linux powershell ubuntu core


【解决方案1】:

-ComputerName 正在寻找一个字符串。

Enter-PSSession -ComputerName '10.10.10.5' -Credential administrator

'10.10.10.5' 现在的 TypeName 为 System.String

谢谢,蒂姆。

【讨论】:

  • 错误与使用'string'时相同。
【解决方案2】:

目标机器是否正确设置了 PowerShell 远程处理?根据目标机器,您可能需要手动设置。

见:Enabling Remoting Article

从那篇文章...

  1. 右键单击 Windows PowerShell 快捷方式并选择以管理员身份运行,以管理员身份启动 Windows PowerShell。

  2. WinRM 服务默认配置为手动启动。您必须将启动类型更改为自动并在您要使用的每台计算机上启动该服务。在 PowerShell 提示符下,您可以使用以下命令验证 WinRM 服务是否正在运行: 获取服务 winrm 输出中 Status 属性的值应该是“Running”。

  3. 要配置 Windows PowerShell 以进行远程处理,请键入以下命令: Enable-PSRemoting –force

【讨论】:

  • 是的,它已启用。我可以从 Windows 桌面到该服务器执行 Enter-PSSession,而不是从 Linux/docker powershell 到同一服务器,据我了解,ansible 也使用相同类型的连接(winrm)。
猜你喜欢
  • 2014-04-18
  • 1970-01-01
  • 2019-01-09
  • 2015-11-11
  • 1970-01-01
  • 2022-12-31
  • 1970-01-01
  • 2020-04-03
  • 1970-01-01
相关资源
最近更新 更多