Solved

DOS Command  OR Scripts

Posted on 2013-11-19
6
349 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 84

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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