invoke命令似乎不工作-我用winrm了吗?cmd正确配置托管主机?

时间:2021-12-30 21:48:22

I am not sure if I used winrmcmd to configure TrustedHosts correctly

我不确定是否使用了winrmcmd来正确配置托管主机。

I am running commands in PowerShell from host_computer (part of workgroup)

我正在用PowerShell从host_computer(工作组的一部分)运行命令

$cred = Get-Credential -credential user

Prompt appears, and I enter in password

提示符出现,我输入密码

invoke命令似乎不工作-我用winrm了吗?cmd正确配置托管主机?

Then I execute a command so setup.exe will execute on remote_computer (also part of workgroup)

然后执行一个命令。exe将在remote_computer(也是工作组的一部分)上执行

invoke-command -ComputerName remote_computer -credential $cred -scriptBlock {& 'C:\share\setup.exe'}

Error appears:

出现错误:

[remote_computer] Connecting to remote server remote_computer failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client 
computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the 
TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (remote_computer:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : ServerNotTrusted,PSSessionStateBroken

I follow steps according to http://pubs.vmware.com/orchestrator-plugins/index.jsp#com.vmware.using.powershell.plugin.doc_10/GUID-D4ACA4EF-D018-448A-866A-DECDDA5CC3C1.html

我按照http://pubs.vmware.com/orchestrator-plugins/index.jsp#com.vmware.using.powershell.plugin.doc_10/GUID-D4ACA4EF-D018-448A-866A-DECDDA5CC3C1.html的要求遵循以下步骤

On host_computer I open command prompt (shift, right-click, select "run as administrator") and execute the following

在host_computer上,我打开命令提示符(shift,右键单击,选择“run as administrator”)并执行以下操作

C:\Windows\system32>winrm quickconfig

C:\Windows\system32>winrm e winrm/config/listener

C:\Windows\system32>winrm get winrm/config

C:\Windows\system32>winrm set winrm/config/service/auth @{Basic="true"}

C:\Windows\system32>winrm set winrm/config/service @{AllowUnencrypted="true"}

C:\Windows\system32>winrm set winrm/config/client @{TrustedHosts="remote_computer"}

On remote_computer I open command prompt (shift, right-click, select "run as administrator") and execute the following

在remote_computer中,我打开命令提示符(shift,右键单击,选择“run as administrator”)并执行以下操作。

C:\Windows\system32>winrm get winrm/config

C:\Windows\system32>winrm set winrm/config/client/auth @{Basic="true"}

C:\Windows\system32>winrm set winrm/config/client @{AllowUnencrypted="true"}

C:\Windows\system32>winrm set winrm/config/client @{TrustedHosts="host_computer"}

C:\Windows\system32>winrm identify -r:http://host_computer:5985 -auth:basic -u:user -p:password -encoding:utf-8

And I get the following response

我得到了如下的回应

IdentifyResponse
    ProtocolVersion = http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
    ProductVendor = Microsoft Corporation
    ProductVersion = OS: 6.3.9600 SP: 0.0 Stack: 3.0
    SecurityProfiles
        SecurityProfileName = http://schemas.dmtf.org/wbem/wsman/1/wsman/secprof
ile/http/basic, http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/spneg
o-kerberos

Now when I go to host_computer and execute

现在,当我到host_computer并执行时

invoke-command -ComputerName remote_computer -credential $cred -scriptBlock {& 'C:\share\setup.exe'}

I no longer get any error messages, but when I remote into remote_host, I don't see setup.exe in the Task Manager. It's been more than half an hour, and I cannot find any evidence that the file executed.

我不再收到任何错误消息,但是当我远程访问remote_host时,我看不到setup。任务管理器中的exe。已经超过半个小时了,我找不到任何证据证明文件被执行了。

How to troubleshoot?

如何解决?

2 个解决方案

#1


0  

After adding TrustedHosts using wmirm.cmd (see OP), the following command works

使用wmirm添加托管主机后。cmd(参见OP),以下命令有效

invoke-command -ComputerName remote_Computer -credential $cred -scriptBlock {cmd /c 'C:\share\setup.exe'}

#2


0  

Along with disabling the firewalls on both the machineA and machineB, and executing winrm set winrm/config/client @{TrustedHosts="machineB"} on machine A, I could then call Invoke-Command -FilePath c:\scripts\test.ps1 -ComputerName machineB

除了在机器和机器上禁用防火墙,并在机器A上执行winrm设置的winrm/config/client @托管="machineB"},我还可以调用invoke命令-FilePath c:\scripts\test。ps1 -ComputerName machineB

this link was also helpful http://pubs.vmware.com/orchestrator-plugins/index.jsp?topic=%2Fcom.vmware.using.powershell.plugin.doc_10%2FGUID-D4ACA4EF-D018-448A-866A-DECDDA5CC3C1.html

这个链接也很有用:http://pubs.vmware.com/orchestratorins/index.jsp?

#1


0  

After adding TrustedHosts using wmirm.cmd (see OP), the following command works

使用wmirm添加托管主机后。cmd(参见OP),以下命令有效

invoke-command -ComputerName remote_Computer -credential $cred -scriptBlock {cmd /c 'C:\share\setup.exe'}

#2


0  

Along with disabling the firewalls on both the machineA and machineB, and executing winrm set winrm/config/client @{TrustedHosts="machineB"} on machine A, I could then call Invoke-Command -FilePath c:\scripts\test.ps1 -ComputerName machineB

除了在机器和机器上禁用防火墙,并在机器A上执行winrm设置的winrm/config/client @托管="machineB"},我还可以调用invoke命令-FilePath c:\scripts\test。ps1 -ComputerName machineB

this link was also helpful http://pubs.vmware.com/orchestrator-plugins/index.jsp?topic=%2Fcom.vmware.using.powershell.plugin.doc_10%2FGUID-D4ACA4EF-D018-448A-866A-DECDDA5CC3C1.html

这个链接也很有用:http://pubs.vmware.com/orchestratorins/index.jsp?