2014-08-27 474 views
3

我不知道如果我用winrmcmd配置TrustedHosts正確invoke-command似乎不工作 - 我是否使用winrm.cmd正確配置TrustedHosts?

我從host_computer運行在PowerShell命令(工作組的一部分)出現

$cred = Get-Credential -credential user 

提示,我在密碼輸入

enter image description here

然後我執行一個命令,這樣setup.exe將在remote_computer上執行(也是工作組的一部分)

出現
invoke-command -ComputerName remote_computer -credential $cred -scriptBlock {& 'C:\share\setup.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

在host_computer我打開命令提示符(移動,單擊鼠標右鍵,選擇「以管理員身份運行」),並執行以下

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"} 

在REMOTE_COMPUTER我打開命令提示符(移動,單擊鼠標右鍵,選擇「以管理員身份運行」)和exec UTE以下

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 

我也得到如下回應

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:\share\setup.exe'} 

我不再收到任何錯誤消息,但遠程當我到remote_host,我沒有看到任務管理器中的setup.exe。已經有半個多小時了,我找不到任何證據表明文件已經執行。

如何排除故障?

+1

在腳本塊像'{「測試」也許嘗試一個簡單的命令| Out-File'C:\ Test.txt'}'看看你是否在遠程機器上生成了這個文件。 – TheMadTechnician 2014-08-27 18:19:58

+0

@TheMadTechnician是的,這個命令工作 – Glowie 2014-08-27 18:26:59

+0

@ theMadTechnician仍然困惑setup.exe,雖然 – Glowie 2014-08-27 18:32:36

回答

0

添加使用wmirm.cmd TrustedHosts後(見OP),下面的命令工作

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