How can I resolve multiple External URLs with Powershell - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Microsoft Windows and Software
Click Here to Login
Reply
 
Thread Tools Display Modes
 
Old 08-23-2019, 11:56 AM   #1 (permalink)
Newb Techie
 
Join Date: Aug 2019
Location: Ireland
Posts: 1
Default How can I resolve multiple External URLs with Powershell

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"
__________________

__________________
malware_j is offline   Reply With Quote
Old 08-24-2019, 10:59 AM   #2 (permalink)
i2D
Monster Techie
 
i2D's Avatar
 
Join Date: Jan 2015
Location: Earth
Posts: 1,731
Default Re: How can I resolve multiple External URLs with Powershell

Quote:
Originally Posted by malware_j View Post
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"
}
__________________
~Retired from Techist~
i2D is offline   Reply With Quote
Reply

Tags
powershell, windows

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Multiple URLs In Firefox Osiris Tips, Tricks & Tutorials 0 11-03-2008 07:03 AM
Cannot resolve IP using certain utilities (or how I loathe wireless) canooten Computer Networking and Internet Hardware 2 04-25-2008 01:48 PM
resolve ip to netbios name using ping -a hollor Computer Networking and Internet Hardware 0 05-09-2005 03:31 PM
Resolve ip by username scj6771 Computer Networking and Internet Hardware 11 01-29-2005 01:58 PM
How do UNIX clients resolve names? chesman Computer Networking and Internet Hardware 6 03-21-2004 01:11 PM



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 07:56 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2019, vBulletin Solutions, Inc.