Solved

Batch script to check service status on remote windows servers

Posted on 2014-07-30
8
738 Views
Last Modified: 2014-10-27
HI,

I am looking for a batch script which can check perticular service status on 4-5 servers from my desktop and retrives output to a file.Could you please advice?

Regards,
Rahul
0
Comment
Question by:Rahul Patil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 40230904
what you want from service status ? what service is  ? something like that  Service.DisplayName  , Service.ServiceAccountName ,Service.Path    ,Service.Status..etc

Please write us more in detail & Please advise

Duncan
0
 
LVL 4

Expert Comment

by:rastoi
ID: 40231380
this way ? Just provide in current path "servers.txt" one target per line and change "bits" in my example to your desired service
for /f %%i in (servers.txt) do (
for /f "tokens=4" %%a in ('"sc \\%%i query bits |findstr /i "state""') do (
echo %DATE% %TIME% %%i %%a >>log.txt
))

Open in new window


and I used this like chance to refresh my powershell fomatting. Here is PS 3.0 one liner example
Get-Content .\servers.txt | % {Get-Service -ComputerName $_ |? name
 -eq bits} | ft @{n='timestamp';e={get-date}},machinename, status -hide |Out-Str
ing -stream|? length -gt 0 |Out-File .\log.txt -Append -Encoding utf8

Open in new window

0
 
LVL 4

Author Comment

by:Rahul Patil
ID: 40233289
Hi,

I want to check RSA service status on 8 severs.For each server  different credentials will be used.I just need an output in a file stating weather RSA service is up or not.Also need to check repliction status in application logs automatically.Could you please help?

Regards,
Rahul
0
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
LVL 4

Expert Comment

by:rastoi
ID: 40233528
Hi Rahul,
1. I can tune for you batch, but need more information. How are you checking the RSA status manually ? Are you going to authentication interface or just queriing its service status? What are the OS on servers and source for checking (your workstation?). Is powershell good for you too?  Please be a bit more descriptive.
2. extending question to different topic is not in line with EE rules.  Please raise extra question for replication checking and be more descriptive on what do you need. What kind of replication? are there exact records you want to be aware of? what should be an action resulting from such check ?

Kind regards, Rasto
0
 
LVL 4

Author Comment

by:Rahul Patil
ID: 40239484
HI,

I am using windows xp to RDP to the RSA serevrs.While manual check I mstsc/RDP to each serevr and then check RSA service status manually.For replication checks I filter eventviewer  Appliaction logs with RSA and check replication status for all replicas.Looking for automation/Batch script will be ok.I guess i can not use powershell as I am using xp :(.Kindly advice

Regards,
Rahul
0
 
LVL 4

Expert Comment

by:rastoi
ID: 40244209
1. please download and unpack sysinternals suite on your workstation
http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx
2. but test connectivity to your remote servers using psservice. From command line in folder where you place sysinternals run:
psservice \\targetserver -u user -p password query rsaservicename
for each your server.
3. if this will work,you can just put all testing lines to one cmd and you have simple script.
4. if it will work you can use similar approach for replications using properly parametrized "psloglist" from suite
0
 
LVL 4

Author Comment

by:Rahul Patil
ID: 40247389
Hi Rastoi,

Appreciate your help but unfortunately I do not have right to install any third party app :(.Kindly adviceif there is any other way or batch script to perform similar activity.

Regards,
Rahul
0
 
LVL 4

Accepted Solution

by:
rastoi earned 500 total points
ID: 40247588
Sysinternals are common admin tools from microsoft not 3rd psrty.
Can you try those commands against server(s):
Net use \\server\ipc$ /user:username
It should ask for password. Let me know error if any. If it pass run this
Sc \\server query reservicename
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: I have always been a big fan of Windows but my liking towards it is slowly being eroded by the variety of other Applications that I encounter, when I browse the Web. Most of the software available is free and maybe Open Source too. …
Many times while working on a computer regardless of any Operating System, lag and crashes seem to creep in, hindering your working speed. Sometimes, it can also cause your work to be lost unexpectedly and as a result, you are unable to meet your de…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question