PowerShell remoting lets you run commands on another computer as if you were sitting at it. Enable it once on the remote machine, then connect with one line:
Enter-PSSession -ComputerName NYC-SRV01 -Credential CONTOSO\maria.lopez
In this tutorial, we’ll set it up step by step with two sample computers, a server named NYC-SRV01 and a desktop named Seattle-PC02.
What is PowerShell remoting?
On Windows, remoting runs over WinRM, Microsoft’s version of the WS-Management protocol. It listens on TCP port 5985 for HTTP and 5986 for HTTPS. PowerShell 7 can also connect over SSH (port 22), including to Linux and macOS.
You can use it in two ways:
| Style | Cmdlet | Good for |
|---|---|---|
| One-to-one (interactive) | Enter-PSSession | Poking around one server, like a remote console |
| One-to-many | Invoke-Command | Running the same script on many computers |
| Persistent session | New-PSSession | Several commands that share variables |
The computer you type on needs no setup to send commands; only the receiving computer needs remoting enabled. Not sure which shell you’re in? Here’s how to check your PowerShell version.
Step 1: Check whether WinRM is running
Start with two read-only checks: the WinRM service and Test-WSMan, which asks WinRM to answer. I ran them on my Windows 11 desktop, where remoting is still off:
$svc = Get-Service -Name WinRM
"WinRM service: $($svc.Status), startup type: $($svc.StartType)"
try {
Test-WSMan -ComputerName localhost -ErrorAction Stop
}
catch {
$msg = $_.Exception.Message -replace '(?s).*<f:Message>(.*?)\. Verify.*', '$1'
"Failed. $msg."
}
Output:
WinRM service: Stopped, startup type: Manual
Failed. The client cannot connect to the destination specified in the request.

How does this code work?
Get-Service reads the WinRM status without changing it. On client Windows, the service isn’t running by default, so Test-WSMan fails. Windows PowerShell 5.1 printed the same two lines.
A working computer returns its WS-Management protocol version instead. To test the port from another machine, see how to check if a port is open in PowerShell.
Step 2: Enable PowerShell remoting on the remote computer
Run this on NYC-SRV01 in a console opened with Run as administrator. I didn’t run it on my test PC, so it’s shown as code only:
# Run as administrator on the computer that RECEIVES commands
Enable-PSRemoting -Force
It starts WinRM, sets it to Automatic, creates a listener and adds a firewall exception. Windows Server 2012 and later have remoting on already.
My full walk-through on how to enable WinRM using PowerShell covers public networks and Group Policy.
Session se