HOWTO: Remotely Change DNS Settings

Betweentimes you need to update multiple computers with DNS settings. Instead of doing this one by one manually you can automate it so it can be done in one go, from a plain PowerShell script. It's simple but very effective. This article shows how to remotely change DNS settings.

1. Start Windows PowerShell

Click Start, type PowerShell, and then click Windows PowerShell.

2. Use This Simple Script to Set the Dns Server Ip Addresses on a Network Card Based on Its Name

function Set-DnsServerIpAddress {
[string] $ComputerName,
[string] $NicName,
[string] $IpAddresses
if (Test-Connection -ComputerName $ComputerName -Count 2 -Quiet) {
Invoke-Command -ComputerName $ComputerName -ScriptBlock { param ($ComputerName, $NicName, $IpAddresses)
write-host "Setting on $ComputerName on interface $NicName a new set of DNS Servers $IpAddresses"
Set-DnsClientServerAddress -InterfaceAlias $NicName -ServerAddresses $IpAddresses
} -ArgumentList $ComputerName, $NicName, $IpAddresses
} else {
write-host "Can't access $ComputerName. Computer is not online."

3. The Using Is so Simple

# Where $ServerName (set as you need)
# Where Service (name of the Network Card (takes wildcard))
# Where IpAddresses (in brackets)
>Set-DnsServerIpAddress -ComputerName $ServerName -NicName "Service*" -IpAddresses '','',''

Also consider using Action1 to remotely change DNS settings if:

  • - You need to perform this action on multiple (hundreds or even thousands) computers simultaneously.
  • - Some of your endpoints are laptops not connected to corporate network at all times.

Action1 is a cloud-based platform for software deployment, software/hardware inventory, patch management, endpoint configuration and more. It is free with basic functionality.

Other Relevant HOWTOs: