Search code examples
powershellnslookup

reverse lookup multiple IP's


If I do the below on a computer I get two IP's back. Nowthen, I want to extract both IP's and then do a reverse lookup on them - ie "nslookup IPADDRESS".

How do I extract each entry and then let it do a reverse lookup on the address?

$computername = gc env:computername
[System.Net.Dns]::GetHostByName($computername) | select AddressList

AddressList                                                                                                                                                  
-----------                                                                                                                                                  
{10.171.80.249, 10.171.80.82}    

Solution

  • try:

    [System.Net.Dns]::GetHostByName($computername) | select -expa AddressList |
     select -expa ipaddresstostring | % { nslookup $_ }