Solved

Batch script to check service status on remote windows servers

Posted on 2014-07-30
8
549 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Nathan Brom/Bromy2004 Introduction There are numerous websites out there for any different type of program you can imagine.  Of those, you'll need to decide which ones are legitimate and aren't trying to steal your money or infect your comput…
Log files are useful in diagnosing and repairing problems.  This is a list of common log files and their standard locations that I've compiled.   While this is not exhaustive, it is a pretty good list that I've found to be useful.  I may update it f…
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…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now