Set DNS Search Order & Server

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

Set DNS Search Order & Server

Setzt die DNS Eintr├Ąge in "Preferred DNS Server", "Alternate DNS Server" und in der "DNS search order" unter den Advanced settings.

$computer = "SERVER1"
$DNSServers = [array]("169.254.0.2", "169.254.0.3", "169.254.0.4", "169.254.0.5")

$Adapter = get-wmiobject -namespace "root\CIMV2" -query "select * from Win32_NetworkAdapterConfiguration where IPEnabled = True" -computer $computer -ErrorVariable $wmiError

Foreach($NIC in $Adapter) {
if(!($wmiError)){
$NIC.DNSServerSearchOrder
$NIC.SetDNSServerSearchOrder($DNSServers)
}
else{Write-Host $wmiError}
}