Set DNS Server IP Address Using PowerShell

In this blog post, I will show you how to set the DNS server IP address on a Windows Server or Windows 10 machine.


Using PowerShell, we can programmatically configure hosts with specific settings without using the GUI.

This is good for the environment where we want to automate the configuration or have a copy-paste approach to configuration.

This method also keeps the configuration the same all the time and prevent errors.

Get Network Adapter ID

The first step in our configuration it to find out the ID of our network adapter so we could set the DNS server.

We do that using the following cmdlet, run it and note down the ifIndex number of your network adapter.


Set DNS Server

The next step will be running the following cmdlet to set the DNS server, as shown below.

Note: Below there are two examples, one for a single DNS server and the second for multiple DNS servers.

Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ("")
Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ("", "")

Success! You're on the list.