4

We have quite a few Windows based servers and I'm attempting to figure out either A. How I can change all of their DNS settings automatically (they all have local static IPs) or, failing that, B. at least query what their DNS settings are and sort by those that're using our old DNS servers.

We have both SCCM and SCOM if that helps in the situation.

  • this is why DHCP was invented – JamesRyan Jun 2 '10 at 16:25
  • DHCP for servers? – Massimo Jun 2 '10 at 19:14
  • and definately dhcp for servers, works great if you know what your doing! – tony roth Jun 2 '10 at 22:22
  • I know you can use reservations, but there are some services which will complain a lot (or just not start at all) if they see the server doesn't have a static IP address. Also, you can not use DHCP for servers that need more than one single address and/or have more than one NIC. – Massimo Jun 3 '10 at 5:47
4

Got powershell? There's a script that does basically what you want (also sets WINS server, but you can easily chop the line out).

And if you're not comfortable just changing configurations with powershell, this version will simply list the servers and their DNS settings:

function Set-DNSWINS {
$NICs = Get-WmiObject Win32_NetworkAdapterConfiguration -Computer $_ -Filter "IPEnabled=TRUE"

foreach($NIC in $NICs) {echo $_ $NIC.DNSServerSearchOrder}
}

function Get-FileName {
$computer = Read-Host "Filename of computer names?"
return $computer
}

$f = Get-FileName
Get-Content $f | foreach {Set-DNSWINS}

The easiest way to run this is to copy and paste all the but last line into a powersheel, enter the name of the file (you'll need a file with the servernames whitespace separated) then copy and paste the last line.

  • I take it this works via WMI so it doesn't have any requisites on the servers themselves right? – tearman Jun 2 '10 at 15:23
  • Yeah, this is all done via WMI. If you have tightened up the firewall it may fail, but otherwise there's no special requirement for the servers. – Chris S Jun 2 '10 at 15:32
  • Epic answer by the way, this is great! Thank you. – tearman Jun 2 '10 at 15:57
1

another answer less work!

wmic /node:listofnames.txt nicconfig where "ipenabled='true'" call SetDNSServerSearchOrder ("x.x.x.x"),("x.x.x.x")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.