Query windows service status remotely
I was working on tuning SCOM for Exchange and reached a point where SCOM services where stopped on some/more servers. Well, we got the heartbeat functionality with SCOM, but thought I’d write a script to check status of services remotely.
So we are trying to:
Query a windows service with displayname OpsMgr Health Service and name
HealthService on all servers in a txt file
The output will reflect the Servername, Service Name, Startup Type and current state
- Create a folder and name it Scripts
- Create a txt file with the name of all servers you need to query the status and name it ServerList.txt
- Open Powershell, navigate to scripts folder and type:
Get-WmiObject win32_service -filter “Name=’HealthService'” -comp (gc ServerList.txt) | select __Server, Name, Startmode, State
4. If you are only interested in getting the output with servers with the service stopped, run this:
Get-WmiObject win32_service -filter “Name=’HealthService’ and State=’Stopped'” -comp (gc ServerList.txt) | select __Server, Name, Startmode, State
Ratish Nair
MVP Exchange
Team @MSExchangeGuru
Keywords: Services On Remote Windows Computers, Service status on remote machines, find Service status on remote machines, how to find stopped service for a list of servers
November 20th, 2011 at 3:43 am
can you make it more detail, i try to run by adding some more lines so that it should send email whenever the service state is stopped.