locked
Ping machines in a text file RRS feed

  • Question

  • I have a text file list of computers I want to ping with Powershell.   The file name is "list.txt".   How can I ping each name in the list, one at a time, and output the results either to the screen or output it to another text file?  Can I just output "pass" or "fail" to the text file?   I  need examples because I am very new to this.  Thanks.
    Tuesday, February 19, 2019 8:34 PM

Answers

  • get-content hosts.txt | test-netconnection

    • Marked as answer by Paratus Wednesday, February 20, 2019 10:37 AM
    Wednesday, February 20, 2019 8:07 AM

All replies

  • Please post your script.  If you are asking for someone to write a script then post here: Forum for Script requests

    You can also easily search for scripts that do what you ask.


    \_(ツ)_/

    Tuesday, February 19, 2019 8:51 PM
  • Please post your script.  If you are asking for someone to write a script then post here: Forum for Script requests

    You can also easily search for scripts that do what you ask.


    \_(ツ)_/

    In Windows command line it is:    FOR /F %%I in (list.txt) DO (ping %%I -n 2)     or     FOR /F %%I in (list.txt) do (ping %%I -n2 >>results.txt)    but I need it in Powershell so I can substitute "ping" with a different Powershell  command.

    Tuesday, February 19, 2019 8:59 PM
  • "ping" works in PowerShell.

    also:

    help test-connection -online


    \_(ツ)_/

    Tuesday, February 19, 2019 9:08 PM
  • Search the web for something like "powershell ping systems using file". You'll find many examples like this one:

    https://gallery.technet.microsoft.com/scriptcenter/Ping-Multiple-Servers-ba915a7c


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, February 19, 2019 9:12 PM
  • It is interesting that almost none of these new people coming into computing seem to know how to sue a search engine.  I remember the old search engines from the early web.  They were almost useless for most things.  The new search engines are awesome.  I can find anything I want I only  few seconds and the results are returned in less than a second.  I seldom do anything without first searching for documents, example or code.  I can search f history, literature, art and music items that I want to know about.

    It seem we have created a bunch of people who haven't learned how to use the web because there is so much interest in entertainment, social posting and games.  Information, the thing the web is best at, is not used by most people coming into computing recently.

    Most new users do not seem to know that the whole reason Berners-Lee built the web was to give scientists and engineers a way to quickly find information.

    We should have a requirement that all kids must learn how to use search engines before entering high school.


    \_(ツ)_/

    Tuesday, February 19, 2019 9:24 PM
  • Amen, brother.  ;-)  :-D

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, February 19, 2019 9:34 PM
  • It is interesting that almost none of these new people coming into computing seem to know how to sue a search engine.  I remember the old search engines from the early web.  They were almost useless for most things.  The new search engines are awesome.  I can find anything I want I only  few seconds and the results are returned in less than a second.  I seldom do anything without first searching for documents, example or code.  I can search f history, literature, art and music items that I want to know about.

    It seem we have created a bunch of people who haven't learned how to use the web because there is so much interest in entertainment, social posting and games.  Information, the thing the web is best at, is not used by most people coming into computing recently.

    Most new users do not seem to know that the whole reason Berners-Lee built the web was to give scientists and engineers a way to quickly find information.

    We should have a requirement that all kids must learn how to use search engines before entering high school.


    \_(ツ)_/

    Wow a rude, condescending, unhelpful answer—from the moderator of the forum no less.   

    All your years in computing obviously did not teach you how to be courteous or helpful to people, and therefore I will seek help elsewhere.

    Tuesday, February 19, 2019 10:11 PM
  • Ahhh, yes. Archie and Gopher. The days before web crawlers and spiders.

    I even remember reading "Computer Lib / Dream Machines". Early days, indeed!


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Wednesday, February 20, 2019 3:40 AM
  • Wow a rude, condescending, unhelpful answer—from the moderator of the forum no less.   

    All your years in computing obviously did not teach you how to be courteous or helpful to people, and therefore I will seek help elsewhere.

    But he is right. You are asking for a thing, that was already answered thousands of times. Its so common task that you will find in matter of seconds, if u try.  And, he already answered your question (help test-connection -online).

    Wednesday, February 20, 2019 6:34 AM
  • Wow a rude, condescending, unhelpful answer—from the moderator of the forum no less.   

    All your years in computing obviously did not teach you how to be courteous or helpful to people, and therefore I will seek help elsewhere.

    Not rude. Just teasing you for not using obvious methods for getting answers t trivial questions.  Would you post in a technical forum to find out what time it is?

    The commentary is intended to make help you remember that this is a technical forum and not a place to ask for free script writing.  The concensus is that the question has been answered hundreds of times.  Any technician would know that but many newbies just don't stop to think and refuse to learn the technology they wish to work wit.

    Try to put in some effort and you will find answers more easily.  Also learn to take advise from more experienced technicians. Pointers on how to learn a technology are invaluable to newcomers tot he technology.


    \_(ツ)_/

    Wednesday, February 20, 2019 6:44 AM
  • get-content hosts.txt | test-netconnection

    • Marked as answer by Paratus Wednesday, February 20, 2019 10:37 AM
    Wednesday, February 20, 2019 8:07 AM
  • get-content hosts.txt | test-netconnection

    Thank you JS2010.
    Wednesday, February 20, 2019 10:37 AM
  • Wow a rude, condescending, unhelpful answer—from the moderator of the forum no less.   

    All your years in computing obviously did not teach you how to be courteous or helpful to people, and therefore I will seek help elsewhere.

    But he is right. You are asking for a thing, that was already answered thousands of times. Its so common task that you will find in matter of seconds, if u try.  And, he already answered your question (help test-connection -online).

    No, you are wrong.  He did not answer it.  I wasn't asking about how to test network connectivity, that was just an example.  You didn't read the original question closely enough.  I was asking how to perform a repeated operation on a list of machines in a text file.  JS2010 answered it so you can take off your scolding hat now.
    Wednesday, February 20, 2019 10:42 AM
  • Sorry about your anger but it would be best if you took some time to learn PowerShell.  It is not that hard to learn but cannot be learned by asking questions.  Technology requires more than just guessing. 


    \_(ツ)_/

    Wednesday, February 20, 2019 10:49 AM