PowerShellRemotingWinRM6 min read

Enable PowerShell Remoting

Enable PowerShell Remoting to manage your server remotely with scripts.


PowerShell Remoting lets you execute commands and scripts on your Windows VPS remotely, without needing RDP.

Step 1 — Enable WinRM on the server

powershell
Enable-PSRemoting -Force

This configures the WinRM service, creates an HTTP listener, and adjusts the firewall.

Step 2 — Configure for external access

By default, WinRM only accepts connections from the local network. For remote access:

powershell
# Configure TrustedHosts (allow any IP)
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

# Or allow only specific IPs
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.100,10.0.0.5" -Force

Step 3 — Configure HTTPS (recommended)

powershell
# Create self-signed certificate
$cert = New-SelfSignedCertificate -DnsName $env:COMPUTERNAME -CertStoreLocation Cert:\LocalMachine\My

# Create HTTPS listener
New-Item -Path WSMan:\localhost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint -Force

# Open port 5986 in firewall
New-NetFirewallRule -DisplayName "WinRM HTTPS" -Direction Inbound -Protocol TCP -LocalPort 5986 -Action Allow

Step 4 — Connect from your local machine

powershell
# Interactive session
Enter-PSSession -ComputerName YOUR_IP -Credential Administrator

# Execute remote command
Invoke-Command -ComputerName YOUR_IP -Credential Administrator -ScriptBlock {
    Get-Service | Where-Object Status -eq "Running" | Measure-Object
}

Step 5 — Persistent sessions

powershell
# Create reusable session
$session = New-PSSession -ComputerName YOUR_IP -Credential Administrator

# Execute multiple commands in the same session
Invoke-Command -Session $session -ScriptBlock { Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 }
Invoke-Command -Session $session -ScriptBlock { Get-EventLog -LogName System -Newest 5 }

# Close session
Remove-PSSession $session

Step 6 — Copy files remotely

powershell
# Copy file to server
Copy-Item -Path .\deploy.zip -Destination C:\apps\ -ToSession $session

# Copy file from server
Copy-Item -Path C:\logs\app.log -Destination .\ -FromSession $session

Step 7 — Execute complete scripts

powershell
Invoke-Command -ComputerName YOUR_IP -Credential Administrator -FilePath .\my-script.ps1

Security

powershell
# View current configuration
Get-PSSessionConfiguration

# Limit who can connect
Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI

PowerShell Remoting is ideal for automating administration of your Baires Host Windows VPS without opening RDP sessions.


Was this guide helpful?