This is not a UNIX / Linux question, though.
There are, say, 10 Windows 2008 servers on the Intranet. MS SQL Server 2008 R2 is running on them.
I want to write a script in Perl (preferred) or else in PowerShell that can alert (email) me if MS SQL Server Service is not running on any of the Windows Servers. I want to place this script on my local Windows 7 system. So, if email/alert is not working, it can still pop-up messages on my screen when I run the script manually.
Usually, this happens (in this organisation) when Windows Servers got shutdown or somebody manually stop the MS SQL Service and does not start it later. This is critical as these servers are part of ETL which needs to be fine.
I have not written scripts on Windows, so people, any help?
P.S.: This command tells me the status of the specified service on my local system. I want to write a script on my local system that can tell me the status of the service on 10 servers:
C:\Users\Dev>sc query MSSQL$SQLEXPRESS
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0