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
Solved

Batch script to check service status on remote windows servers

Posted on 2014-07-30
8
612 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
GPO - Set RDP access for specific OU Admin only 4 29
Iphone getting millions of invitations 9 99
windows server backup failing 3 41
RDP Trouble shooting 12 112
This article describes how to set permissions to allow a limited-permissions user to start and stop a particular System Service.   It is always best to give users only the permissions that they need to perform their job, so tweaking particular permi…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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). …
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…

839 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