Applications Systems

PowerShell script error. Connecting to remote server failed

Failed with the following error message : The WinRM client cannot process the request. Need to set trusted hosts. TrustedHosts. Typically occurs on Powershell component monitors, AppInsight for IIS, and AppInsight for Exchange.

First published date

8/13/2019 4:48 PM

Last published date

2/11/2025 7:17 PM

Overview

The error is received when setting up PowerShell script monitors in SAM. This is typically due to TrustedHosts not set on both the polling server and the target server. This is not the only thing that can product this error message, if the following steps do not work, contact SolarWinds Support.

Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

Product section

Server Application Monitor

Cause

This issue occurs when trusted hosts are not set on SolarWinds Platform and target server.

Resolution

Set trusted hosts. This applies to both poller assigned to the node and the Microsoft IIS server

  1. Open PowerShell as Administrator.
  2. Run this command to view TrustedHosts value: 
    /* Scripts are not supported under any SolarWinds support program or service. 
    Scripts are provided AS IS without warranty of any kind. SolarWinds further 
    disclaims all warranties including, without limitation, any implied warranties 
    of merchantability or of fitness for a particular purpose. The risk arising
    out of the use or performance of the scripts and documentation stays with you.
    In no event shall SolarWinds or anyone else involved in the creation,
    production, or delivery of the scripts be liable for any damages whatsoever
    (including, without limitation, damages for loss of business profits, business
    interruption, loss of business information, or other pecuniary loss) arising
    out of the use of or inability to use the scripts or documentation. */
    Get-Item WSMan:\localhost\Client\TrustedHosts
  3. To set TrustedHosts value: 
    winrm set winrm/config/client '@{TrustedHosts="*"}'
    This command sets the TrustedHosts to asterisk which is a Wildcard. You may replace this with the server IP that it needs to trust (comma separated for multiple servers). Target server needs to trust the polling engine IP, and the polling engine IP needs to trust the target server IP. It is recommended that polling engines are always set to asterisk since it may be polling multiple servers and needs to trust those servers.
  4. View the newly set TrustedHosts with the Get-Item command in Step 2.

If using templates, AppInsight for IIS or AppInsight for Exchange, you may need to set the application to use a HTTP listener instead of a HTTPS listener (default setting is an HTTPS listener). To Create a WinRM HTTPS listener in Orion , you may follow that article. 

To change the https listener type, edit the application monitor (Go to the Application Details page > Edit application monitor in the upper right or in the Management resource).Change the PowerShell- Windows URL from the default (https://${IP}:5986/wsman/) to the http listener (http://${IP}:5985/wsman/) if you have not built a https listener in the article above.