Posted in
Windows Server |
No Comment | 965 views | 13/06/2014 22:13
This is an example script to check DNS servers on remote servers. If DNS count is not equal to 4, that will add server name into output.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| # DNS Server Control
$ServerList = Get-Content VMs.txt
foreach ($Server in $ServerList)
{
Write-Host $Server
$DNSServers = $Null
$DNSServers = (Get-WmiObject -ComputerName $Server -Class Win32_NetworkAdapterConfiguration | where {$_.DNSServerSearchOrder -ne $Null}).DNSServerSearchOrder
if ($DNSServers.Count -ne "4")
{
Add-Content -Value $Server -Path DNSProblem.txt
}
Write-Host $DNSServers
Write-Host " "
Write-Host " "
} |
# DNS Server Control
$ServerList = Get-Content VMs.txt
foreach ($Server in $ServerList)
{
Write-Host $Server
$DNSServers = $Null
$DNSServers = (Get-WmiObject -ComputerName $Server -Class Win32_NetworkAdapterConfiguration | where {$_.DNSServerSearchOrder -ne $Null}).DNSServerSearchOrder
if ($DNSServers.Count -ne "4")
{
Add-Content -Value $Server -Path DNSProblem.txt
}
Write-Host $DNSServers
Write-Host " "
Write-Host " "
}
You should check DNSProblem.txt file to see which servers don’t have 4 DNS entries.