Techibee.com

Start/Stop/Restart service on remote computer with powershell

Today I got a requirement to restart a service on remote computer. I thought of doing it with powershell using restart-service powershell cmdlet but it disappointed me. Though Get-Service cmdlet is offering -computername parameter, stop-service, start-service, and restart-service cmdlets are not offering this feature. That means you can query service status on remote PC but cannot start/stop with built-in facilities/cmdlets.

However, there is a way to do it using WMI in combination with powershell.


(Get-WMIObject -computername remotepc -class win32_service "Name='alerter'").stopservice()

(Get-WMIObject -computername remotepc -class win32_service "Name='alerter'").startservice()

There is no direct method available to restart a service directly, but you can achieve similar functionality with stop followed by start method which makes sense.

You like to know what more we can do here? Just issue below command.


(Get-WMIObject -computername remotepc -class win32_service "Name='alerter'") | gm

Exit mobile version