Agent skill
remote-management
Manage remote Windows servers via WinRM, PowerShell remoting, and SSH. Use when user needs to execute commands on remote hosts or establish remote sessions.
Install this agent skill to your Project
npx add-skill https://github.com/djcyphers/network-copilot-cli/tree/main/skills/remote-management
SKILL.md
Remote Server Management Skill
When to Activate
- User mentions: remote, WinRM, PSRemoting, Enter-PSSession, Invoke-Command, SSH
- User wants to run commands on another server
- User needs to manage multiple servers at once
Prerequisites
Enable WinRM on Target
# On target server (run as admin)
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force # Or specific hosts
Verify Connectivity
Test-WSMan -ComputerName $remoteHost
Test-NetConnection -ComputerName $remoteHost -Port 5985 # HTTP
Test-NetConnection -ComputerName $remoteHost -Port 5986 # HTTPS
Remote Execution Patterns
Single Command to Single Host
Invoke-Command -ComputerName $remoteHost -ScriptBlock {
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5
}
Single Command to Multiple Hosts
$servers = @('Server01', 'Server02', 'Server03')
Invoke-Command -ComputerName $servers -ScriptBlock {
[PSCustomObject]@{
Host = $env:COMPUTERNAME
Uptime = (Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime
FreeMemGB = [math]::Round((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB, 2)
}
} | Select-Object Host, Uptime, FreeMemGB
Interactive Session
# Enter interactive session
Enter-PSSession -ComputerName $remoteHost
# Exit when done
Exit-PSSession
With Credentials
$cred = Get-Credential
Invoke-Command -ComputerName $remoteHost -Credential $cred -ScriptBlock { whoami }
# Or use stored credential
$cred = New-Object PSCredential("DOMAIN\User", (ConvertTo-SecureString "password" -AsPlainText -Force))
Pass Variables to Remote
$serviceName = "Spooler"
Invoke-Command -ComputerName $remoteHost -ScriptBlock {
param($svc)
Get-Service -Name $svc
} -ArgumentList $serviceName
# Or using $using: scope (PS 3.0+)
Invoke-Command -ComputerName $remoteHost -ScriptBlock {
Get-Service -Name $using:serviceName
}
Copy Files to Remote
# Using PS remoting session
$session = New-PSSession -ComputerName $remoteHost
Copy-Item -Path "C:\local\file.txt" -Destination "C:\remote\" -ToSession $session
Remove-PSSession $session
SSH Alternative (OpenSSH)
Connect via SSH
ssh user@$remoteHost
# Run single command
ssh user@$remoteHost "Get-Process | Select -First 5"
PowerShell over SSH
# Requires OpenSSH and PowerShell subsystem configured
Enter-PSSession -HostName $remoteHost -UserName $username -SSHTransport
Parallel Execution (PS 7+)
$servers = @('Server01', 'Server02', 'Server03', 'Server04', 'Server05')
$servers | ForEach-Object -Parallel {
Invoke-Command -ComputerName $_ -ScriptBlock {
[PSCustomObject]@{
Server = $env:COMPUTERNAME
CPU = (Get-CimInstance Win32_Processor).LoadPercentage
}
}
} -ThrottleLimit 5
Troubleshooting WinRM
| Error | Solution |
|---|---|
| "WinRM cannot complete the operation" | Enable WinRM: Enable-PSRemoting -Force |
| "Access denied" | Check credentials, group membership |
| "The WinRM client cannot process the request" | Add to TrustedHosts or use HTTPS |
| Connection timeout | Check firewall (5985/5986), network path |
# Diagnose WinRM issues
winrm quickconfig
winrm get winrm/config/client
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
server-health
Check Windows Server health: CPU, memory, disk, services, event logs, uptime. Use when user asks about server performance or wants a health check.
active-directory
Query and manage Active Directory: users, groups, computers, OUs, GPO status. Use when user asks about AD objects or domain information.
network-diagnostics
Diagnose network connectivity issues: DNS, routing, firewall, port checks, traceroutes. Use for troubleshooting server-to-server communication or client access problems.
setup-pre-commit
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
handoff
Compact the current conversation into a handoff document for another agent to pick up.
edit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
Didn't find tool you were looking for?