Canberra, Australia
To be provided
To be provided

Change DNS Server for Network Interface Powershell

Harmik Batth Tech Blog

Change DNS Server for Network Interface Powershell

As a System Administrators, you will be asked or required to use specific DNS for specific computers. This can be very easily done via GUI, but require few steps to perform it. Also you may need to do this on number of computers.

For me, I normally perform actions via powershell if I have to do certain tasks more than twice.

So To change the DNS Server foe a particular Interface, you can use a cmdlet called Set-DnsClientServerAddress. 

The Set-DnsClientServerAddress cmdlet sets one or more IP addresses for DNS servers associated with an interface. This cmdlet statically adds DNS server addresses to the interface. If this cmdlet is used to add DNS servers to the interface, then the DNS servers will override any DHCP configuration for that interface.

But before we do it, we need to know the Interface index or alias to perform this action.

Get-NetAdapter or Get-DNSClient, will give you Interface alias and Index.

you can use either of the following command to do so

Set-DnsClientServerAddress -InterfaceAlias “InterfaceAliasName”
Set-DnsClientServerAddress -InterfaceIndex “InterfaceIndexno”


Then you will to specify switch “-ServerAddresses”, which is used to specifies a list of DNS server IP addresses to set for the interface.

Lets quickly check ipconfig details or current DNS Settings


As you can see that DNS Server is pointing to twice and needs to be fixed. So I will run the Set-DnsClientServerAddress cmdlet to fix it.

Set-DnsClientServerAddress -InterfaceAlias “Ethernet0” -ServerAddresses “,”

This will set the DNS Servers for that particular Interface to “,”


After the Set-DnsClientServerAddress is run, DNS Server addresses are fixed.


Good thing about Powershell that you can invoke this same command on any number of Computers at once. For e.g. you can run this command on 100 servers in couple of seconds only and fixed the lot.


Lastly, please do give feedback. Enjoy Reading.


No Comments

Add your comment