others - 调用命令似乎不起作用, 是否使用 winrm.cmd 配置 TrustedHosts?


$cred = Get-Credential -credential user

提示出现,我输入密码

enter image description here


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

出现错误:


[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

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


C:Windowssystem32>winrm quickconfig

C:Windowssystem32>winrm e winrm/config/listener

C:Windowssystem32>winrm get winrm/config

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

C:Windowssystem32>winrm set winrm/config/service @{AllowUnencrypted="true"}

C:Windowssystem32>winrm set winrm/config/client @{TrustedHosts="remote_computer"}


C:Windowssystem32>winrm get winrm/config

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

C:Windowssystem32>winrm set winrm/config/client @{AllowUnencrypted="true"}

C:Windowssystem32>winrm set winrm/config/client @{TrustedHosts="host_computer"}

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

我得到了以下响应


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

当我进入host_computer,并执行


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

我不再获得错误信息,但是,当远程进入remote_host时,在任务管理器中看不到setup.exe,

如何排除故障?

时间:

在使用wmirm.cmd (请参阅操作)添加trustedhosts之后,以下命令,


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

...