This little chunk of goodness came in handy recently while helping a customer with DNS issues on their domain controllers.  It can be a bit slow to execute when hitting machines across slow WAN links, so you might want to test with MaxNumber at a lower number first.  Be careful to unwrap the code so that it ends up on eight (8) lines as indicated.

1. Import-Module "ActiveDirectory"
2. $MaxNumber = 30
3. 
4. $x2 = (Get-ADForest).Domains | %{Get-ADDomainController -Filter * -Server $_} |
5. Select-Object Name -First $MaxNumber |
6. ForEach-Object {Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $_.Name -Filter {IPEnabled=true} } |
7. Select-Object DNSHostName,@{Name="IPv4"; Expression = {$_.IPAddress[0]}}, @{Name="Mask"; Expression = {$_.IPSubnet[0]}},MACAddress,@{Name="Gateway"; Expression={$_.DefaultIPGateway[0]}},DHCPEnabled,@{Name="DNS Servers"; Expression={$_.DNSServerSearchOrder -join ' '}} | 
8. Sort-Object -Property "DNSHostName" | Out-GridView -Title "Domain Controller Network Configs"
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s