Invoke-command doesn't seem to work. Did I use winrm.cmd to set up TrustedHosts correctly?

I'm not sure if I was using winrmcmd to set up TrustedHosts correctly.

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

$cred = Get-Credential -credential user

      

A prompt appears and I enter my password

enter image description here

Then I execute the command so that setup.exe will be executed on remote_computer (also part of the workgroup)

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

      

An error message 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 the steps as per http://pubs.vmware.com/orchestrator-plugins/index.jsp#com.vmware.using.powershell.plugin.doc_10/GUID-D4ACA4EF-D018-448A-866A-DECDDA5CC3C1.html

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

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

      

In remote_computer, I open a command prompt (shift, right click, select "run as administrator") and do the following

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

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

      

I don't get any error messages anymore, but when I delete to remote_host, I don't see setup.exe in the task manager. It's been over an hour and a half and I can't find any evidence that the file was executed.

How do I troubleshoot?

+3


source to share


2 answers


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



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

      

0


source


Along with disabling the firewalls on both machineA and machineB, and executing winrm set winrm/config/client @{TrustedHosts="machineB"}

on machine A, I could then callInvoke-Command -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

0


source







All Articles