WinRM and Enter-PSSession Across Domains
WinRM and Enter-PSSession Across Domains
Use this process when your client is not joined to the same domain as the target server, or when you need to connect by IP address.
What changed during troubleshooting
Enter-PSSessionstill failed because WinRM over HTTP requiresTrustedHostswhen Kerberos cannot be used.- Connecting by IP address disables Kerberos.
- Connecting by hostname can still require
TrustedHostsif the client is not joined to the target domain or there is no trust relationship.
Prerequisites
- WinRM enabled on the remote server
- TCP
5985open for HTTP WinRM, or TCP5986for HTTPS WinRM - Credentials for the remote domain
- Elevated PowerShell session on the client to modify
TrustedHosts
Validate connectivity from the client
Check DNS resolution:
| |
Check network reachability:
| |
Check basic WinRM response:
| |
Enable WinRM on the remote server
Run these commands locally on the destination server if WinRM is not already configured:
| |
Verify the network profile if the firewall rule is still too restrictive:
| |
Configure TrustedHosts on the client
If Kerberos cannot be used, add the remote host to TrustedHosts.
Set a single host:
| |
Set both hostname and IP address:
| |
Append entries without overwriting the current list:
| |
Verify the setting:
| |
Start the remote PowerShell session
Prompt for credentials:
| |
Connect by hostname:
| |
Connect by IP address:
| |
If needed, make the authentication choice explicit:
| |
Use credentials in one of these forms:
| |
Recommended command sequence
This is the shortest working flow for an HTTP WinRM connection to a host in another domain:
| |
Common errors
TCP port open but Enter-PSSession fails with TrustedHosts error
Cause: the host is reachable, but Kerberos is unavailable and the client does not trust the target for WinRM over HTTP.
Fix:
| |
nslookup works but Enter-PSSession says the name cannot be resolved
Cause: nslookup uses DNS directly, but Windows name resolution used by WinRM may still fail because of adapter DNS settings or missing host records.
Fix:
| |
If needed, add a temporary hosts entry:
| |
Path:
| |
Test-WSMan fails before authentication
Cause: WinRM is not enabled, the listener is missing, or a firewall rule is blocking access.
Fix:
| |
More secure option
TrustedHosts is acceptable for internal administrative use, but HTTPS WinRM is better because the server identity is validated with a certificate.
If the remote server has a WinRM HTTPS listener on port 5986, use:
| |