Remoting and Automation
Managing 200 Servers from My Desk
Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock {
Set-Service -Name "wuauserv" -StartupType Automatic
Start-Service -Name "wuauserv"
} | Select-Object PSComputerName, StatusPowerShell Remoting Basics
Enabling WinRM
# Run as Administrator
Enable-PSRemoting -Force
# Check WinRM service
Get-Service WinRM
# Test remoting (to itself)
Test-WSMan localhostOne-to-One Remoting: Enter-PSSession
One-to-Many Remoting: Invoke-Command
Using Credentials
PowerShell Sessions
Creating Sessions
Multiple Sessions
Session Benefits
SSH Remoting (PowerShell 7+)
Setup SSH
Passing Arguments
Using -ArgumentList
Multiple Arguments
Using $using:
Background Jobs
Starting Jobs
Remote Jobs
Real-World Examples
Health Check Across Servers
Parallel Deployment
Log Collection
Security Considerations
Using CredSSP (Carefully)
Just Enough Administration (JEA)
Common Pitfalls
1. Firewall Blocking WinRM
2. The Double-Hop Problem
3. Forgetting to Remove Sessions/Jobs
Key Takeaways
What You've Learned
Next Steps
Last updated