Link to home
Start Free TrialLog in
Avatar of Scotch Tech
Scotch TechFlag for United States of America

asked on

Script to Ping/Resovle names given IP

I have a list of IP's that I need to get the computer names for and status. How can I script this?
ASKER CERTIFIED SOLUTION
Avatar of Elango Sathyadev
Elango Sathyadev
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Dent
Shorter, but without progress.
function Get-State {
    [CmdletBinding()]
    param(
        [Parameter(ValueFromPipeline = $true)]
        [String]$IPAddress
    )

    process {
        try {
            $HostName = [System.Net.Dns]::GetHostEntry($IPAddress).HostName
        } catch {
            $HostName = ""
        }

        [PSCustomObject]@{
            IPAddress      = $IPAddress
            HostName       = $HostName
            RespondsToPing = Test-Connection $IPAddress -Quiet -Count 2
        }
    }
}

Get-Content TheListOfIPs.txt | Get-State

Open in new window

Avatar of Scotch Tech

ASKER

Damn, those are some intimidating looking scripts! Thanks, I'll test them both out.
thanks