Use this when running commands on remote Windows machines with PowerShell.
PowerShell Remoting · Remote Access
PowerShell Remoting runs commands on remote computers over WinRM or SSH with Enter-PSSession for interactive sessions and Invoke-Command for one or many machines. Enable it with Enable-PSRemoting.
1. Test-WSMan <host>.
2. Invoke-Command -ComputerName <host> { hostname }.
3. Access denied → Remote Management Users / admin.
4. Workgroup → HTTPS or TrustedHosts.
5. JEA endpoints for least privilege.
client → WinRM → auth → session config → command
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Adding
*to TrustedHosts to make NTLM work. - Using CredSSP everywhere to solve the second hop (exposes credentials).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Remoting runs over WinRM, or over SSH in PowerShell 7.
- Kerberos is used inside a domain.
- The double-hop problem blocks access to a third server.
Test-NetConnection <host> -Port 3389— RDP portGet-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections— RDP enabled (0)Test-WSMan <host>— WinRMGet-Service sshd— OpenSSH server
ReferenceWhy it matters1 section · depth on demand
How it works
PowerShell Remoting uses WinRM (WS-Management) over HTTP 5985 or HTTPS 5986. Enable-PSRemoting starts WinRM, creates listeners and firewall rules. In a domain, Kerberos authenticates and encrypts the session even over HTTP. Commands run on the remote machine in a session endpoint (Microsoft.PowerShell by default; JEA endpoints restrict what users can run). Credentials are not passed on, which causes the second hop problem.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
The second-hop problem, concretely
PS C:\> Invoke-Command -ComputerName srv01 -ScriptBlock { Get-ChildItem \\fs01\share }
Access is denied.
With Kerberos (the default in a domain), srv01 has a ticket for your session on srv01 but no credentials to authenticate to fs01. The command works locally on srv01, and fails only when it reaches a third machine.
Options Microsoft documents, and when to use them
| Option | Security | Use when |
|---|---|---|
| Resource-based Kerberos constrained delegation | Good — configured on the target (fs01) | A defined set of servers needs to reach a defined resource |
| Kerberos constrained delegation | Good | Same, configured on the middle server |
| JEA endpoint with a virtual or gMSA account | Good | Delegating specific admin tasks |
Pass -Credential inside the script block | Acceptable for one-off admin | Credentials sent explicitly for the inner call |
PSSessionConfiguration with RunAs | Medium | Fixed admin endpoints |
| CredSSP | Weak — full credentials cached on srv01 | Avoid; only for isolated lab tasks |
| Unconstrained delegation | Weak | Avoid |
Resource-based constrained delegation example:
$srv01 = Get-ADComputer srv01
Set-ADComputer fs01 -PrincipalsAllowedToDelegateToAccount $srv01
klist purge -li 0x3e7 # on srv01, refresh its tickets
Connection basics worth checking first
| Check | Command |
|---|---|
| WinRM listening | Test-WSMan srv01 |
| Listener types | winrm enumerate winrm/config/listener |
| Firewall | TCP 5985 (HTTP) / 5986 (HTTPS) |
| Authentication used | Kerberos needs the name, not the IP; IP or workgroup → NTLM + TrustedHosts or HTTPS |
Avoid weakening settings to make it work
Set-Item WSMan:\localhost\Client\TrustedHosts * disables server identity checks for NTLM. Prefer HTTPS listeners with a certificate for non-domain machines, or SSH-based remoting in PowerShell 7 (Enter-PSSession -HostName srv01 -UserName admin).
*The PowerShell remoting second-hop example above are illustrative examples, not captured from a lab or production system.*
Commands
Enable-PSRemoting -Force
Test-WSMan srv01
Invoke-Command -ComputerName srv01,srv02 -ScriptBlock { Get-Service Spooler }
Enter-PSSession srv01
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Remote Access → PowerShell Remoting. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/ · confidence 94%