Start/Stop/Restart service on remote computer with powershell

by Sitaram Pamarthi on August 17, 2010

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.

(gwmi -computername remotepc -class win32_service “Name=’alerter'”).stopservice()

(gwmi -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.

(gwmi -computername remotepc -class win32_service “Name=’alerter'”) | gm

This post was written by...

– who has written 503 posts on Techibee.com.

Sitaram Pamarthi is a windows administrators with 9+ years of experience.read more

Previous post:

Next post: