In this article I’m going to show how to connect to remote hosts and how to configure the list of Trusted Hosts. Because with the introduction of Windows Server Core and Nanoserver, the significance of Windows PowerShell Remoting has increased.
For remoting, you can also use Remote Desktop, as described in my article: How to enable Remote Desktop and establish a Remote Desktop Session (Windows 10 / Windows Server). But this article is all about PowerShell Remoting.
I am logged on to a client computer as a domain administrator. Now i try to connect to server spagr02, which is located in the same domain than me. spagr02 is running Windows Server 2016. In Windows Server 2012 / 2016 Remote Management is enabled by default. In Windows Server 2008 run winrm qc to enable Remote Management.
Enter-PSSession -ComputerName spagr02
It works like a charm. In a domain environment.
The list of Trusted Hosts with IPv4
If the computers are not in a shared domain, authentication information must be supplied with the -credential parameter, and both computers must trust each other. Keyword: TrustedHosts!
We have to configure Trusted Hosts on both computers. They have to trust each other for establishing a remote connection.
Set-Item wsman:\localhost\client\TrustedHosts -Value 192.168.0.103 -Force
Then try to connect to the remote host by using the Credential parameter.
Enter-PSSession -ComputerName HostName -Credential nano500\administrator
The list of Trusted Hosts with IPv6
To configure Trusted Hosts with IPv6 we have to place the IPv6 Link-Local Address in brackets.
Set-Item wsman:\localhost\client\TrustedHosts -Value [fe80::bc11:fa91:8674:99ba] -Force Enter-PSSession -ComputerName fe80::bc11:fa91:8674:99ba -Credential nano500\administrator
Safety is over-estimated – Configure * 😉
The list of trusted hosts can also be set to *. Then all computers can establish a remote session to the host.
Set-Item wsman:\localhost\client\TrustedHosts -Value * -Force
Most of the PowerShell Cmdlets support the parameter -ComputerName. For checking installed Software on remote remote hosts, it´s easier to run a One-Liner with the parameter -ComputerName, instead of establishing a remote session: Windows Server: List all installed Roles and Features using PowerShell
If you don’t like SSH, use the PowerShell built-in remote feature, which I have described in my article: PowerShell: Use SSH to connect to remote hosts (Posh-SSH)
Categories: PowerShell, Windows 10, Windows Server
9 replies »