How can I resolve multiple External URLs with Powershell

malware_j

Beta member
Messages
1
Location
Ireland
I am trying to resolve about 7000 URLs to IP addresses.
I have attempted multiple methods and I am trying to use powershell to query these addresses. I have used the below script, however my result keeps coming back empty.
Could you advise on whats wrong with the script or if there are better/other methods or tools I could use to resolve this. Thanks.

$hostnames = Get-Content "list.txt"
foreach($hostname in $hostnames){
$ip = ([System.Net.Dns]::GetHostAddresses($hostname)).IPAddressToString
write-host "$hostname : $ip"
 
I am trying to resolve about 7000 URLs to IP addresses.
I have attempted multiple methods and I am trying to use powershell to query these addresses. I have used the below script, however my result keeps coming back empty.
Could you advise on whats wrong with the script or if there are better/other methods or tools I could use to resolve this. Thanks.

$hostnames = Get-Content "list.txt"
foreach($hostname in $hostnames){
$ip = ([System.Net.Dns]::GetHostAddresses($hostname)).IPAddressToString
write-host "$hostname : $ip"




That is correct, but your missing closing } at the end of your script.


Should be:


$hostnames = Get-Content "list.txt"
foreach($hostname in $hostnames)
{
$ip = ([System.Net.Dns]::GetHostAddresses($hostname)).IPAddressToString
write-host "$hostname : $ip"
}
 
Back
Top Bottom