PowerShell - Get IP and online status from text list
- Jon Boyette
- Jan 11, 2022
- 1 min read
Save the contents named.ps1 as desired, Populate c:\temp\servers.txt, nice on screen of IP resolve and Online/Offline status
cat c:\temp\servers.txt |
ForEach{
$result=@{
HostName=$_
HostAddress=''
Status='Unreachable'
}
Try{
$result.hostAddress=[System.Net.DNS]::GetHostByName($_).AddressList[0]
$result.Status='Online'
}
Catch{
}
New-Object PSObject -Property $result
}
Comments