With the rise of Server Core installations in Windows Server 2008 and later versions, command-line administration has become essential. While GUI tools like MMC snap-ins offer remote connection options, native CLI tools require specific configuration for remote management.
The most built-in solution is WinRM, which powers PowerShell remoting. First, enable it on the target server:
winrm quickconfig
Then connect from your management machine:
winrs -r:servername -u:username -p:password cmd
For more advanced management, PowerShell remoting is the preferred approach:
# Enable PS Remoting on target server
Enable-PSRemoting -Force
# Create persistent session
$cred = Get-Credential
$session = New-PSSession -ComputerName Server01 -Credential $cred
# Execute commands remotely
Invoke-Command -Session $session -ScriptBlock { Get-Service }
Modern Windows versions support OpenSSH server:
# Install SSH server feature
Add-WindowsFeature -Name OpenSSH-Server
# Start the service
Start-Service sshd
# Connect from Linux/macOS/WSL:
ssh administrator@server01
- psexec: For one-off command execution
- RDP for CLI: mstsc /admin /v:server:3389
- Windows Admin Center: Web-based tool with CLI integration
Always use encrypted protocols (HTTPS for WinRM, SSH for command line). Configure firewalls to allow only specific ports:
netsh advfirewall firewall add rule name="WinRM HTTPS" dir=in action=allow protocol=TCP localport=5986
If you encounter "Access Denied" errors:
# Check WinRM listener
winrm enumerate winrm/config/listener
# Verify firewall rules
Get-NetFirewallRule -DisplayGroup "Windows Remote Management"
While GUI tools like Server Manager dominate Windows administration, CLI remains crucial for:
- Server Core installations (no GUI available)
- Automation through scripts
- Low-bandwidth remote connections
- Repetitive administrative tasks
Windows Remote Management (WinRM) - The foundation for most modern CLI administration:
# Enable WinRM on target server (run as admin)
winrm quickconfig
# Connect from client machine
winrs -r:servername -u:username -p:password cmd
PowerShell Remoting - More powerful than basic CMD:
# One-time setup on target server
Enable-PSRemoting -Force
# Establish session
$cred = Get-Credential
Enter-PSSession -ComputerName SERVER01 -Credential $cred
# Run commands directly
Get-Service | Where-Object {$_.Status -eq "Running"}
SSH Server (Windows 10/2019+) - Familiar *NIX-style access:
# Install OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Connect from any SSH client
ssh admin@server01
RSAT Tools - Microsoft's Remote Server Administration Tools provide CLI equivalents for many GUI functions.
Service Management:
# Restart service remotely via PowerShell
Invoke-Command -ComputerName SERVER01 -ScriptBlock {
Restart-Service -Name "Spooler" -Force
}
Event Log Querying:
# Get last 10 system events
wevtutil qe System /c:10 /rd:true /f:text
Automating Server Core Setup:
# Unattended network config
netsh interface ipv4 set address "Ethernet" static 192.168.1.10 255.255.255.0 192.168.1.1
netsh interface ipv4 set dnsservers "Ethernet" static 8.8.8.8
Always:
- Use encrypted protocols (WinRM over HTTPS, SSH)
- Implement Just Enough Administration (JEA)
- Restrict access via firewalls
- Audit remote sessions
Some tasks still require GUI tools, particularly:
- Active Directory Users and Computers
- Group Policy Management
- Performance Monitor analysis