Solved

Batch script to check service status on remote windows servers

Posted on 2014-07-30
8
660 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Hallo! I guess almost every Windows Administrator must have got stumped with this question "Where does WINDOWS store a users cached credentials? Every user who had once logged onto a Server/Desktop while it was connected to the domain could sti…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

730 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