Setting DNS settings

HI all

I was wondering if someone might be able to help me recently deployed some new domain controllers and we are looking at repointing our servers to the new DNS servers.

I have tried to run the following, pulling the server names from a text file.

$Computers = Get-Content C:\Temp\AllServers.txt
ForEach ($Computer in $Computers)
{
Get-NetAdapter | Set-DNSClientServerAddress ServerAddresses (10.0.0.10,10.0.0.11) -Verbose
}

now it says its completed with out issue but it actually only updates the dns on the server its ran from

could someone help

Chris

August 26th, 2015 8:07am

Hi Chris,

Get-NetAdapter doesn't have a -ComputerName parameter, so you can only use it locally.

You could either use remoting to run your script (not the best idea) or use GP (better idea) to set these settings:

https://technet.microsoft.com/en-us/library/dd197486%28v=ws.10%29.aspx

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 8:13am

HI all

I was wondering if someone might be able to help me recently deployed some new domain controllers and we are looking at repointing our servers to the new DNS servers.

I have tried to run the following, pulling the server names from a text file.

$Computers = Get-Content C:\Temp\AllServers.txt
ForEach ($Computer in $Computers)
{
Get-NetAdapter | Set-DNSClientServerAddress ServerAddresses (10.0.0.10,10.0.0.11) -Verbose
}

now it says its completed with out issue but it actually only updates the dns on the server its ran from

could someone help

Chris

I've never done it this way but I believe this is what you're looking for.

-CimSession<CimSession[]>

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

August 26th, 2015 8:13am

cheers Mike ill have a look into that
Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 8:15am

Cheers Dan ill have a look into that
August 26th, 2015 8:16am

Hi,

Please checkout the below script,  

$computer = get-content C:\myfolder\Textfile.txt
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq TRUE}
  Foreach($NIC in $NICs) {
$DNSServers = Primary DNS ip",Secondary DNS ip"
 $NIC.SetDNSServerSearchOrder($DNSServers)
 $NIC.SetDynamicDNSRegistration(TRUE)
}

Refernce Link:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/ed3f4c9e-1467-4795-b9d1-ae41937b8962/script-to-change-dns-servers-on-remote-
August 26th, 2015 9:17am

Hi,

Please checkout the below script,  

$computer = get-content C:\myfolder\Textfile.txt
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq TRUE}
  Foreach($NIC in $NICs) {
$DNSServers = Primary DNS ip",Secondary DNS ip"
 $NIC.SetDNSServerSearchOrder($DNSServers)
 $NIC.SetDynamicDNSRegistration(TRUE)
}

Refernce Link:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/ed3f4c9e-1467-4795-b9d1-ae41937b8962/script-to-change-dns-servers-on-remote-
August 26th, 2015 10:46am

I would set all systems up with DHCP so all things are configurable centrally. Just set lease option to infinite.

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 12:09pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics