Lesson 5 of 13 · 16m
WinRM Is the SSH You Already Have
PSRemoting rides WinRM on TCP 5985/5986 with Kerberos-or-NTLM auth, and the double-hop problem is Kerberos working as designed.
Windows already has an SSH-equivalent, and it's been on your servers since Server 2008: WinRM, Microsoft's WS-Management implementation, carrying SOAP envelopes over HTTP on TCP 5985 or HTTPS on 5986. PowerShell Remoting is a client of that service, not a separate protocol — Enable-PSRemoting just starts winrm, registers a listener, and opens the firewall. Every Invoke-Command you run is an authenticated, encrypted HTTP conversation with a service that was already listening on half your estate.
Turning it on
On a server, Enable-PSRemoting -Force does three things: starts and auto-starts the WinRM service, creates an HTTP listener on *:5985, and adds firewall rules. -SkipNetworkProfileCheck handles the case where the NIC is on a Public profile. On Server 2012 R2 and later it's enabled by default — your member servers and clients are the ones that need the cmdlet. Test-WSMan server01 from your workstation tells you whether a listener answers; Get-Service winrm tells you the service state. The configuration itself lives in the WSMan: PSDrive — WSMan:\localhost\Client\TrustedHosts, WSMan:\localhost\Service\MaxEnvelopeSizekb, WSMan:\localhost\Shell\MaxShellsPerUser — so Set-Item WSMan:\localhost\Client\TrustedHosts 'server01' is how you adjust it.
Authentication is the hard part, not the transport
The mental model to discard is "remoting = RDP for scripts." RDP sends keystrokes and bitmaps to an interactive session. WinRM establishes a mutually-authenticated channel and runs commands inside a constrained runspace — and mutual is the word that bites you.
In a domain, Enter-PSSession web01 uses Kerberos. Kerberos needs a Service Principal Name, and SPNs are registered to names, not addresses — so Enter-PSSession 10.0.0.15 can't get a ticket, falls back to NTLM, and fails outright unless you've either added the address to TrustedHosts or you're on HTTPS. The error you get ("The WinRM client cannot process the request") is the most-googled remoting string in existence for a reason. The fix is boring: connect by name, not IP.
TrustedHosts is the NTLM escape hatch — Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'server01,server02'. It tells your client "yes, send my password-derived credentials to this machine even though it can't prove its identity." On a flat workgroup network it's the only option; on a real domain it's a list of hosts you trust not to be spoofed, so keep it specific and never *. The grown-up alternative is the HTTPS listener: create it with winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="web01.contoso.com";CertificateThumbprint="AB12..."}, open 5986, and the server's TLS cert provides the mutual authentication Kerberos was giving you for free.
Interactive, ad-hoc, persistent
Three different animals:
Enter-PSSession -ComputerName web01— one interactive remote runspace, one machine. Your prompt shows[web01]: PS>.Exit-PSSessionleaves.Invoke-Command -ComputerName web01,web02 -ScriptBlock { Get-Service w3svc }— ad-hoc fan-out: a session is created, the block runs, the session is destroyed, results come back tagged withPSComputerName. Fan-out is the entire point: fifty servers, one command, parallel by default with-ThrottleLimit(32).New-PSSession web01+Invoke-Command -Session $s {...}— a persistent runspace you keep for repeated calls, imported modules, and state that survives between invocations.
-Credential (Get-Credential) covers all three when your logged-on identity isn't the one that should run things. Invoke-Command -AsJob puts the whole fan-out in the background for Receive-Job later.
The double-hop that eats every beginner
Your credentials arrive on web01 as a remote logon token — and that token cannot authenticate onward to a third machine. Invoke-Command web01 { Get-Content \\fs01\share\app.config } fails with access denied even though running it locally on web01 works perfectly. This is the double-hop problem, and it is not a bug: it's Kerberos doing exactly what it was designed to do, refusing to let an intermediate box impersonate you.
The escapes, in rough order of how often you should reach for them: run the whole job from the machine that legitimately touches the share; set up Kerberos constrained delegation, or better, resource-based constrained delegation (Set-ADComputer fs01 -PrincipalsAllowedToDelegateToAccount web01$) so web01 may delegate to exactly that service; or use Invoke-Command -Authentication CredSSP, which hands web01 a usable credential — fast to set up and exactly why CredSSP is a soft target on pentest reports, since any admin on web01 can now act as you. The JEA endpoints in a later lesson solve it differently: a RunAsVirtualAccount endpoint does the second hop as the machine, which already has its own Kerberos identity (web01$) you can authorize on the share.
The practice
Enable it once (Enable-PSRemoting -Force, or a GPO for the estate), connect by FQDN so Kerberos works, fan out with Invoke-Command, and keep TrustedHosts short or empty. When the second-hop error arrives — and it will — the answer is delegation design, not CredSSP by reflex.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.
Running a Minecraft Network: Four JVMs, One Box, and the Settings That Lie to You
Four servers on one host means four JVMs each sizing its thread pools for a machine it does not own. The measured cost of that, the systemd ordering that guarantees nothing, and the throttle that switches itself back on when your forwarding breaks.
Building a Minecraft Network: Four Servers Pretending to Be One Place
A proxy, a lobby, an SMP and a PvP arena is four JVMs that know nothing about each other. What actually has to be shared, why your permissions don't follow players, and the two LuckPerms defaults that silently share nothing at all.