PowerShell: Stopping Services Remotely

Stop-Service cannot stop services remotely. One easy way of doing so is Set-Service:

Set-Service -Name Spooler -Status "Stopped" -ComputerName targetcomputer

However, unlike Stop-Service, Set-Service has no -Force parameter, so you cannot stop services if they, for example, have running dependent services.

If your infrastructure supports PowerShell Remoting, you could use Invoke-Command instead:

Invoke-Command { Stop-Service -Name Spooler -Force } -ComputerName targetcomputer

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.