?
Solved

Batch script to check service status on remote windows servers

Posted on 2014-07-30
8
Medium Priority
?
826 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
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!

 
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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

My purpose is to describe the basic concepts of virtual memory as implemented in a modern Windows-based operating system. I will also describe the problems inherent in older systems and how virtual memory solves them. The dark ages - before virtu…
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
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…
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…

762 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