Ping Until Find

Ask your Windows 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.
Locked
User avatar
MarvelManiac
Posts: 63
Joined: Mon May 01, 2017 8:28 pm

Ping Until Find

Post by MarvelManiac » Fri Nov 17, 2017 10:31 pm

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!!!

User avatar
jvierra
Posts: 12770
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Ping Until Find

Post by jvierra » Sat Nov 18, 2017 11:57 am

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

Locked