Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Scripts » How to add servers to the Trusted Hosts list
  • CI With GitLab 1
    Build Docker Images with GitLab CI Automation
  • retrieve SSL
    How to Retrieve an SSL Thumbprint in Windows using MMC Windows
  • Error 1069 Windows could not start
    Fix Error 1069: Windows could not start the Veeam backup service on local computer Backup
  • Feature image Install.wim file
    How To Get Install.WIM From Windows 10 Installation File Windows
  • aptira ansible 1
    The module ping was not found in configured module paths, core modules are missing Configuration Management Tool
  • banner 3
    How to Set Network Adapter Priority on Windows 11 Network | Monitoring
  • schedulepythontasksinWindows
    Task Scheduler shows task still running despite successful Windows
  • Screenshot 2020 06 22 at 11.33.46
    How to fix Bluetooth not available on MacBook Mac

How to add servers to the Trusted Hosts list

Posted on 23/03/202018/12/2025 Christian By Christian 4 Comments on How to add servers to the Trusted Hosts list
powershell01
powershell01

In this article, I will show you how to add servers to the Trusted Hosts list via PowerShell and command Prompt for the WinRM client. Please see how to enable and Configure WinRM to accept connection from a specific IP Address. The WSMan provider for PowerShell lets you add, change, clear, and delete WS-Management configuration data on local or remote computers. Please, see Configure Windows Admin Center on Windows Server 2019, and Why Software KVMs such as Synergy is replacing Hardware KVMs.

The WSMan provider exposes a PowerShell drive with a directory structure that corresponds to a logical grouping of WS-Management configuration settings.

For more on WSMan, see the following link. Windows by default have an empty TrustedHosts list, a list that contains those remote computers (hosts) that you can remotely manage from a client without authentication.

Note: In Windows environments using Windows Remote Management (WinRM) can help discover servers using the WinRM protocol. To run PowerShell commands on a device from a remote computer, we have to add the remote machine to the trusted hosts’ list of the host machine.

Remotely manage a list of computers

When you want to remotely manage a list of computers through WinRM (Windows Remote Management), you have to add computers to the TrustedHosts list. Otherwise, you may most likely encounter errors when communicating between the two sides.

For Windows Admin Center Error: Failed to create a scheduled task, there is no disconnected command associated with the runspace. Also, see how to fix “Error: Failed to create a scheduled task, cannot perform the operation because the runspace pool is not in the open state“.

Add servers to the Trusted Hosts list via PowerShell

Using PowerShell, you can see what the current records are in the TrustedHosts file but also how to add new records depending on your scenario.

Ensure the computers (servers) are added to the TrustedHosts. Instead of adding an individual host, use the asterisk (a wild card) to add all subsequent hosts. Note, this is not recommended.

Below are the steps to add a server to the TrustedHosts for the WinRM client. For some troubleshooting tips, see the following link. For errors connecting to a remote server failed and WinRM cannot process the request,.

Set-Item WSMan:localhost\client\trustedhosts -value *

To view the result below, use the command as shown below

Get-Item WSMan:localhost\client\TrustedHosts

Please see How to view and remove Remote Desktop connection history, what are the Concepts of Ansible on Windows using Cygwin, and how to configure a remote server (windows) to Support Ansible.

Add individual servers to the TrustHost

Note: You can add individual servers to the TrustHost via the following methods below.

Set-Item WSMan:localhost\client\trustedhosts -value ServerDC 

In this way, you can add multiple servers to the TrustedHosts for WinRM, provide a single, comma-separated, string of computer names.

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'ServerDC,AnsibleClient'

To make this command run in an unattended mode (silently) without prompting you to acknowledge the security configuration, add the -Force to the command as shown below.

Set-Item WSMan:localhost\client\trustedhosts -value ServerDC -Force

Please see how to fix WinRM cannot complete the operation, verify that the specified computer name is valid, and how to configure servers for remote access.

Read the trusted host list with PowerShell

To read the trusted host list with PowerShell, Please run the command below.

Get-Item WSMan:\localhost\Client\TrustedHosts

To add all domain computers to the TrustedHosts list, use the command as follow, Set-Item WSMan:\localhost\Client\TrustedHosts *.yourdomain.com

Set-Item WSMan:\localhost\Client\TrustedHosts *.techdirect.local

Also, see Enabling and Configuring WinRM via GPO, how to delete User Profile in Windows, and There was an error opening the Trusted Platform Module snap-in: You do not have permission to open the Trusted Platform Module Console.

Add servers to the Trusted Hosts list Via the Command Prompt

Run the following command below

winrm set winrm/config/client @{TrustedHosts="RemoteComputerName"}

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Scripts Tags:add servers to the Trusted Hosts, PowerShell, Trusted Hosts list, Windows 10, Windows 11, Windows Server 2016

Post navigation

Previous Post: How to install the Microsoft PSWindowsUpdate module silently
Next Post: How to create an Advanced Windows Scheduled Task

Related Posts

  • powershell
    How to perform PowerShell syntax check using PSScriptAnalyzer Scripts
  • AzureCloudShell
    Provisioning Azure Resources using Azure Az PowerShell Cmdlet from Cloud Shell AWS/Azure/OpenShift
  • Microsoft Defender
    Attack Surface Reduction Configuration with Microsoft Defender Scripts
  • powershell logo
    Connecting to a remote server failed and WinRM cannot process the request: Error code 0x8009030e occurred while using Kerberos authentication, and a specified logon session does not exist Scripts
  • windows 10 hert
    Windows Management Instrumentation Commands Scripts
  • wacxx
    Test Network Connection to Windows Admin Center Gateway Scripts

More Related Articles

powershell How to perform PowerShell syntax check using PSScriptAnalyzer Scripts
AzureCloudShell Provisioning Azure Resources using Azure Az PowerShell Cmdlet from Cloud Shell AWS/Azure/OpenShift
Microsoft Defender Attack Surface Reduction Configuration with Microsoft Defender Scripts
powershell logo Connecting to a remote server failed and WinRM cannot process the request: Error code 0x8009030e occurred while using Kerberos authentication, and a specified logon session does not exist Scripts
windows 10 hert Windows Management Instrumentation Commands Scripts
wacxx Test Network Connection to Windows Admin Center Gateway Scripts

Comments (4) on “How to add servers to the Trusted Hosts list”

  1. Avatar photo Thierry says:
    13/12/2022 at 9:55 AM

    Best explanation I’ve read about this topic, thanks !

    Log in to Reply
    1. chris Christian says:
      13/12/2022 at 9:01 PM

      Thanks a lot Thierry!

      Log in to Reply
  2. Avatar photo Neil Tyson says:
    28/04/2023 at 5:09 PM

    Thanks, this was helpful. It worked on my OnPrem servers but not my Azure servers. After some investigating it turned out that the Azure firewall was blocking WINRM so we needed to make a firewall change to allow it. Thought it may be useful if anyone else had similar issues.

    Log in to Reply
    1. chris Christian says:
      28/04/2023 at 9:01 PM

      Dear Neil,

      Thank you for finding this post useful and for your input (helping others) as well.

      Cheers!

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • CI With GitLab 1
    Build Docker Images with GitLab CI Automation
  • retrieve SSL
    How to Retrieve an SSL Thumbprint in Windows using MMC Windows
  • Error 1069 Windows could not start
    Fix Error 1069: Windows could not start the Veeam backup service on local computer Backup
  • Feature image Install.wim file
    How To Get Install.WIM From Windows 10 Installation File Windows
  • aptira ansible 1
    The module ping was not found in configured module paths, core modules are missing Configuration Management Tool
  • banner 3
    How to Set Network Adapter Priority on Windows 11 Network | Monitoring
  • schedulepythontasksinWindows
    Task Scheduler shows task still running despite successful Windows
  • Screenshot 2020 06 22 at 11.33.46
    How to fix Bluetooth not available on MacBook Mac

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,839 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.