Check Service Status for List of servers

Hi Readers,

Sharing a quickly written script for checking status of particular service on list of servers.

Download the script from below link, extract it.

https://gallery.technet.microsoft.com/scriptcenter/Check-Service-Status-for-72a990e3

Update the ServicesStatus.ps1

$svc = “MpsSvc”  # Enter the service Name that you want to Monitor

Update servers.txt with server names.

run the batch file & report will be extracted in csv format in logs directory.

################################################################# 
#       Author: Vikas Sukhija 
#       Date: 10/24/2014 
#       Description: ChecK service status 
################################################################# 
########################define Logs############################## 
$date = get-date -format d 
# replace \ by - 
$time = get-date -format t 
$month = get-date  
$month1 = $month.month 
$year1 = $month.year 
 
$date = $date.ToString().Replace(“/”, “-”) 
 
$time = $time.ToString().Replace(":""-"$time = $time.ToString().Replace(" """) 
 
$output = ".\logs\" + "Servicesstatus_" + $date + "_" + $time + "_.csv"  
 
########################Variables################################### 
 
 
$svc = "MpsSvc" 
$servers = get-content servers.txt 
$Collection = @() 
 
$servers | foreach-object{ 
$svcsts=get-service -computername $_ -Name $svc 
 
$sts = “” | select serverName,Status 
 
$sts.serverName = $_ 
$sts.Status = $svcsts.status 
$Collection +$sts 
 
} 
 
$Collection | export-csv $output -notypeinformation 
 
######################################################################
Regards
Sukhija Vikas
Advertisements

2 thoughts on “Check Service Status for List of servers

  1. Hi Sukhija Vikas

    am just gone through the following script..and having some questions…from which location its picking the server names and services details..for example i have 15 servers and 15 servers having 150 services which need to check every day…

    https://gallery.technet.microsoft.com/scriptcenter/Check-Service-Status-for-72a990e3

    https://gallery.technet.microsoft.com/scriptcenter/Monitor-Report-5d1998d4#content

    please help me to get the details…

  2. Both scripts are different:
    second one is more appropriate fro your situation…
    https://gallery.technet.microsoft.com/scriptcenter/Monitor-Report-5d1998d4#content

    you need to define two files in the same folder , one for server & other for services

    example:- (Inside the script at the top than you need to call these two files)

    $EVServerList = Get-Content “.\EvServer.txt”

    $EVServicesList = Get-Content “.\EvServices.txt”

    after that at the end call those two variables

    servicestatus $EVServerList $EVServicesList

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s