The Limitations of the Services GUI
When a background process hangs on a Windows Server (such as the Print Spooler, the IIS Web Service, or a custom database daemon), the standard troubleshooting step is to open services.msc, right-click the offending service, and select “Restart.”
However, if you are managing a cluster of 20 web servers, logging into each machine individually via Remote Desktop (RDP) to click through a GUI is incredibly inefficient. By leveraging PowerShell and Windows Remote Management (WinRM), you can instantly restart a service on a remote machine—or dozens of remote machines simultaneously—from your local workstation.
The Restart-Service Cmdlet
PowerShell provides a dedicated cmdlet for manipulating Windows services: Restart-Service. However, this cmdlet behaves slightly differently depending on the version of PowerShell you are running.
Method 1: PowerShell 5.1 (Legacy)
If you are running the older, built-in Windows PowerShell (version 5.1), the cmdlet does not have a native -ComputerName parameter. You must wrap the command inside an Invoke-Command block to push the execution over the network via WinRM.
To restart the Print Spooler service on a remote server named FILE-SRV-01, open an elevated PowerShell prompt and run:
Invoke-Command -ComputerName "FILE-SRV-01" -ScriptBlock { Restart-Service -Name "Spooler" -Force }
Note: The -Force flag ensures that if the service has dependencies (other services relying on it), they will be automatically restarted as well, rather than generating an error prompt.
Method 2: PowerShell 7 (Modern)
If you have installed the modern, cross-platform PowerShell 7 on your IT workstation, the developers have vastly improved the native cmdlets. You no longer need to use Invoke-Command. You can simply append the -ComputerName flag directly to the restart action.
Restart-Service -Name "Spooler" -ComputerName "FILE-SRV-01" -Force
Restarting Services Across Multiple Servers
The true power of PowerShell is its ability to handle arrays. If your organization has five identical IIS Web Servers sitting behind a load balancer, and you need to restart the World Wide Web Publishing Service (W3SVC) on all of them simultaneously, you can feed an array of names into the command.
Using the legacy Invoke-Command method, it looks like this:
$Servers = @("WEB-SRV-01", "WEB-SRV-02", "WEB-SRV-03", "WEB-SRV-04", "WEB-SRV-05")
Invoke-Command -ComputerName $Servers -ScriptBlock { Restart-Service -Name "W3SVC" -Force }
PowerShell will establish simultaneous WinRM connections to all five servers in parallel, instantly restarting the web services across your entire cluster in less than three seconds.