resolving hosts to ip addresses in bulk

Quick and easy Powershell script to resolve servers in a text document to ip addresses:

I’m using h:book1.txt as my source in this case, change this for the textfile you wish to query.

$servers =@()
$servers += get-content h:book1.txt
foreach ($server in $servers){
$ip = [System.Net.Dns]::GetHostAddresses(“$server”)
write-host $server – $ip
}

Voila! (this will also work in reverse)

Related Posts

New Module: Creating an RDP file password with Pow... Here's something that is surprisingly tricky to automate in this day and age. Creating a password and storing it in an RDP file. I'm not here to debat...
Dealing with multi numbered versions in powershell... So here's a quick little blog about something i discovered in powershell while googling today. Lots of vendors like to use version numbers includin...
Accurately checking the Citrix PVS “cache in... Citrix Provisioning services "Cache in RAM, overflow to disk", even with it's challenges is something I've always felt was a great idea, hell, I fores...

Leave a Reply