locked
Getting winrm error when using invoke-command on remote computer RRS feed

  • Question

  • Hi,

    I am working on a script to install a simple tool like nodejs on a remote machine. I am using below command line for the same.

    $ScriptBlockContent = {
     param ($ExeorMSIName)
     Invoke-Expression -Command:"cmd.exe /c msiexec /i $ExeorMSIName /quiet" 
    }

    Invoke-Command -ComputerName $IPAddress -credential $Cred -ErrorAction Stop -ScriptBlock $ScriptBlockContent -ArgumentList $ExeorMSIPath

    WMI service is up and running on the remote machine. When I execute above command it gives an error saying

    Verify that the service on the destination
     is running and is accepting requests 

    d. Now when I checked logs of the remote machine in evenviewer one of the system log says that "The WinRM service has received an unsecure HTTP connection from XX.XX.XX.XX. " I am not sure what to be done to fix this?

    Suggest on this please.

    Thanks & Regards,
    Girish

    Thursday, June 22, 2017 10:49 AM

All replies

  • Test with this:

    Invoke-Command -ComputerName $IPAddress -credential $Cred -ScriptBlock {dir c:\ }

    Post the complete error message.


    \_(ツ)_/

    Thursday, June 22, 2017 11:00 AM
  • Hi,

    Thanks for the quick reply. I am using my script i.e. stored in a file. So I was using -FilePath. Can you please modify your suggested line of code with Filepath instead of scriptblock?

    Regards,
    Girish

    Thursday, June 22, 2017 11:19 AM
  • This is the complete error message:

    [gotsvw2378] Connecting to remote server gotsvw2378 failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests.
     Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM se
    rvice: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
    At line:4 char:1
    + Invoke-Command -ComputerName "gotsvw2378" -credential $Cred -ErrorAct ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OpenError: (gotsvw2378:String) [], PSRemotingTransportException
        + FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken

    Thursday, June 22, 2017 11:21 AM
  • This is the complete error message:

    [gotsvw2378] Connecting to remote server gotsvw2378 failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests.
     Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM se
    rvice: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
    At line:4 char:1
    + Invoke-Command -ComputerName "gotsvw2378" -credential $Cred -ErrorAct ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OpenError: (gotsvw2378:String) [], PSRemotingTransportException
        + FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken


    The error message tells us that WinRM is not running or is blocked by the firewall.  Fix WinRM on the remote server.


    \_(ツ)_/

    Thursday, June 22, 2017 11:26 AM
  • Hi,

    Thanks for the quick reply. I am using my script i.e. stored in a file. So I was using -FilePath. Can you please modify your suggested line of code with Filepath instead of scriptblock?

    Regards,
    Girish

    My code is not intended to fix you script.  It is a simple test that needs no file to run.  Just type it at a prompt.

    You can also run "Test-WsMan remotepcname"


    \_(ツ)_/

    Thursday, June 22, 2017 11:28 AM