PS – nslookup to serverlist

Hello together,

here i have a simple but nice snippet. This executes a “nslookup” in powershell on a list of computers.

Small but very effective:

$servers = get-content "path_to_the_file"
foreach ($server in $servers) {
$addresses = [System.Net.Dns]::GetHostAddresses($server)
foreach($a in $addresses) {
"{0},{1}" -f $server, $a.IPAddressToString
}}

~David

Advertisement