Skip to content

Instantly share code, notes, and snippets.

@CallMarl
Created September 26, 2020 15:31
Show Gist options
  • Save CallMarl/fa2fae81bcb687301790332d86821279 to your computer and use it in GitHub Desktop.
Save CallMarl/fa2fae81bcb687301790332d86821279 to your computer and use it in GitHub Desktop.
Remote Connexion to windows server

Manage remote connexion to windows servers

To connect to remote server you need to start specific service named winrm (Windows Remote Management) on both computer (client/server). winrm is also a commande line used to configure the winrm service. Windows Remote Management is base on specific protocol named WS-MAN (WS-Management protocol).

# Start winrm with powershell (client side and server side)
Enable-PSRemoting
# By default powershell load PSDrive for winrm service.
# Set trusted host on (server side)
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.1.*
# Get trusted host
Get-Item WSMan:\localhost\Client\TrustedHosts
# Restart Service Winrm (server side)
Restart-Service WinRM
# Test config (client side)
Test-WSMan SRV-CALLMARL
# Connect to remote serveur (client side)
Enter-PSSession -ComputerName SRV-CALLMARL -Credential SRV-CALLMARL\CallMarl
# Stop service
Disable-PSRemoting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment