Posted in
Windows Powershell |
No Comment | 1,652 views | 23/01/2014 14:40
You can check dns configuration on remote servers with following command:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| $ErrorActionPreference = "silentlycontinue"
for ($i=2; $i -lt 255; $i++)
{
$IP = "192.168.0.$i"
Write-Host "Working on $IP .."
if (!(Test-Connection $IP -Count 1))
{
Write-Warning "Server is not responding.."
}
else
{
Write-Host "Server is up and running.."
$DNS = (Get-WmiObject -ComputerName $IP -Class Win32_NetworkAdapterConfiguration | Where {$_.DNSServerSearchOrder -like "192.168.0.*"})
if ($DNS)
{
Write-Warning "DNS error!"
}
}
} |
$ErrorActionPreference = "silentlycontinue"
for ($i=2; $i -lt 255; $i++)
{
$IP = "192.168.0.$i"
Write-Host "Working on $IP .."
if (!(Test-Connection $IP -Count 1))
{
Write-Warning "Server is not responding.."
}
else
{
Write-Host "Server is up and running.."
$DNS = (Get-WmiObject -ComputerName $IP -Class Win32_NetworkAdapterConfiguration | Where {$_.DNSServerSearchOrder -like "192.168.0.*"})
if ($DNS)
{
Write-Warning "DNS error!"
}
}
}
If dns servers are not like 192.168.0, then it will throw error.