Simple service status checks and changes with powershell

We have a lot of third party applications with which we integrate. This tends to mean that there are a lot of windows services we want to make sure are running.  Typically this is left to operations departments, but sometimes (or to my experience, most times) you want to track this on your own.  Trust but verify.

 

Powershell is great for this. Simply use the Get-Service command with its -ComputerName param.

PS C:\users\scl>Get-Service -Name QuartzServer -ComputerName OMGITSASERVER

Status   Name               DisplayName
------   ----               -----------
Stopped  QuartzServer       Quartz Server

To change the status of the service you query for you can pipe the result to Set-Service.

PS C:\Users\scl2> gsv -Name QuartzServer -ComputerName OMGITSASERVER | set-service -status running



PS C:\Users\scl2> gsv -Name QuartzServer -ComputerName OMGITSASERVER

Status   Name               DisplayName
------   ----               -----------
Running  QuartzServer       Quartz Server

gsv is a default alias of Get-Service.

Leave a Reply

Your email address will not be published. Required fields are marked *