Ping Until Find

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Ping Until Find

Post by MarvelManiac »

Howdy!

I’ve recently stumbled across the job of looking for computers that we should know the location but don’t. So I’m looking to have these computer names in a text file, use get-content to ping each one until found, send ipinfo and logged on user to me via email and then remove the computer from the array, once the array count is zero, send me a final email

Are there any samples of this?

Essentially a very(very) cheap SCCM client

Thanks!!!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Ping Until Find

Post by jvierra »

Here is a simple template for doing this in a loop:

Code: Select all

Get-Content servers.txt |
    ForEach-Object{
        Test-Connection $_
    }
See:
help Get-Content -Online
help Test-Connection -Online
help Send-MailMessage -Online
This topic is 6 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked