Do you like one liners in powershell? Here is the quick and easy way to start, stop, restart a service on remote computer. This doesn’t require PowerShell remoting. That means you can use it against any computer which has windows operating system installed.
So far I have authored two articles on managing services using powershell:
- Start/Stop/Restart service on remote computer with powershell
- PowerShell: Start and stop services on remote computer with alternate credentials
The first one I wrote when I was not matured enough with PowerShell and the second one recently to address a specific requirement where user need to pass alternate credentials to manage services.
As most system administrators love to use poweshell one-liners which avoids any external script/module invocation, I want to share this little one which starts, stops, and restarts a service on remote computer.
Start a service on remote computer:
Start-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
Stop a service on remote computer:
Stop-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
Restart a service on remote computer:
Restart-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
Hope these little ones helps.