سؤال

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}    
هل كانت مفيدة؟

المحلول

try:

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

نصائح أخرى

just pipe your command to the foreach-object cmdlet :

PS>[System.Net.Dns]::GetHostByName($computername) | 
    select AddressList |
    foreach { 
        [System.Net.Dns]::Resolve($_.ToString()) | select hostname
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top