This script will let you query servers on your domain network for DNS server settings and return them in the CSV file.

Script takes text file containing server names:

server1
server2
server3

and returns CSV file with Hostname, DNS Servers, IP Addresses settings

Get-Content .\servers.txt | `
ForEach-Object {
  Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $_ | `
  Where-Object {$_.IPEnabled -match "True"} | `
  Select-Object -property DNSHostName,@{N="DNSServerSearchOrder";
                                    E={"$($_.DNSServerSearchOrder)"}},
                                    @{N='IPAddress';E={$_.IPAddress}}
} | Export-CSV -path servers.csv -NoTypeInformation

Full list of properties you can query using Win32_NetworkAdapterConfiguration class is available at:

http://msdn.microsoft.com/en-us/library/aa394217%28VS.85%29.aspx


Tags: , ,

2 Responses


  1. Junju on 26 Aug 2011

    this doesn’t check for servers that are offline. It terminates with an error as soon as it finds a server that it can’t connect.

  2. [...] simple script will do the work. The source I found on this web site and changed it for my [...]


Leave your comment