2013-01-07 4 views
1

컴퓨터에서 아래의 작업을 수행하면 두 개의 IP가 반환됩니다. 이제는 두 IP를 모두 추출한 다음 역방향 조회 (예 : "nslookup IPADDRESS")를 수행하려고합니다.역방향 조회 다중 IP의 경우

어떻게 각 항목을 추출한 다음 주소에서 역방향 조회를 수행합니까?

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

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

답변

4

시도 :

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

브릴리언트 - 내가 필요로 그냥 뭐. 고마워요! – lara400

+1

확장 속성 +1 +1 –

+0

@ lara400 도와 드리겠습니다. 그리고 모두에게 감사드립니다! –

1

단지 파이프 foreach는 객체 cmdlet으로 명령 :

PS>[System.Net.Dns]::GetHostByName($computername) | 
    select AddressList | 
    foreach { 
     [System.Net.Dns]::Resolve($_.ToString()) | select hostname 
    } 
+0

그 덕분에 - 나는 내가 노력하고있을 때마다 for-each를하고 있지만 언급하지 않는 것을 잊었다! 나는 왜 - 너의 것이 훨씬 잘되고 일하는 것을 본다. 고마워. – lara400

+0

이것은 작동하지 않습니다 ...'$ _. tostring()'이 비어 있습니다. Return localhost –