Home » Powershell » Get IP address and DNS of remote computers

Get IP address and DNS of remote computers

$Computers = GC “c:\temp\servers.txt”

foreach($computer in $computers)
{
Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $Computer | Where-Object {$_.IPEnabled -match "True"} |
Select-Object -property DNSHostName,@{N=”DNSServerSearchOrder”;
E={“$($_.DNSServerSearchOrder)”}},
@{N=’IPAddress’;E={$_.IPAddress}}|export-csv c:\temp\DNSlist.csv -NoTypeInformation -append
#@{N=’DefaultIPGateway’;E={$_.DefaultIPGateway}}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website