Solved

DOS Command  OR Scripts

Posted on 2013-11-19
6
347 Views
Last Modified: 2013-12-04
Hi EE,

I am looking for the scripts or command to ping the list servers that located in domain from text or excel file and get the result in notepad, Could any one help on this? Please and Thank you

Regards,
J Peter
0
Comment
Question by:Jey_P
6 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 100 total points
ID: 39659804
From a command line:
for /f %a in (c:\servers.txt) do ping %a -n 1 >> results.txt

or in a batch file:

@echo off
for /f %%a in (c:\servers.txt) do ping %%a -n 1 >> results.txt

Open in new window

0
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 50 total points
ID: 39659814
Batch file that creates a csv:
@echo off
setlocal
set ServerFile=Servers.txt
set LogFile=%~dpn0.csv
set CsvDelim=,
if exist "%LogFile%" del "%LogFile%"
for /f %%a in ('type "%ServerFile%"') do (
	echo Processing %%a ...
	ping -4 -n 4 %%a | find /i "TTL" >NUL
	if errorlevel 1 (
		>>"%LogFile%" echo %%a%CsvDelim%Error 
		echo ... offline.
	) else (
		echo ... responding.
		>>"%LogFile%" echo %%a%CsvDelim%Success
	)
)
echo Done.
start "" notepad.exe "%LogFile%"

Open in new window

0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39659828
Hope it will help
@echo off
:Start

REM cd "c:\your location if you need"
for /f "tokens=* delims=" %%x in (d:\ping.txt) do ping %%x
echo.
echo.

Open in new window

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 50 total points
ID: 39659837
Wit PowerShell...
Try..
GC C:\Server.txt | % {
$Server = $_
 If (Test-Connection $Server -Quiet){
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "UP"
 	}
 }
 Else{
	 New-Object PSOBJect -Property @{
	 Server = $Server
	 Status = "Down"
         }
 }
} | Export-Csv C:\report.csv -nti

Open in new window

Input file..
ServerA
ServerB
ServerC

Open in new window

0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 25 total points
ID: 39659863
it works with less code
@echo off
:Start
del -f out.txt
REM cd "c:\your location if you need"
REM ping.txt store all your server name
for /f "tokens=* delims=" %%x in (c:\ping.txt) do ping %%x>>out.txt
start  notepad.exe "out.txt"

Open in new window

0
 
LVL 15

Assisted Solution

by:David L. Hansen
David L. Hansen earned 25 total points
ID: 39659867
You can use MS Powershell to do this (and it's free).  Here are a couple of links to show you where people are already doing exactly the same thing you are trying.

http://powergui.org/thread.jspa?threadID=20236

http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_26672523.html

It is included in the Windows Management Framework download here.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

12 Experts available now in Live!

Get 1:1 Help Now