How to set the DNS server address using Powershell?

Powershell can be utilized to set the DNS server on local or remote computers. You could set one or more DNS servers on the computer using Powershell.

To set the DNS server information through Powershell, we will need to find the interface alias of the network interface card. We will follow the process below:

  • we will find the network interface alias using the Get-NetIpConfiguration
  • we will set the DNS server address for the considered network interface alias
  • we will validate the new DNS server addresses by fetching the DNS information using Powershell

Find the current DNS address

To find the current DNS server address and the interface alias, we will use the following command:


The result of this command will get us the network interface alias as well as the current DNS server addresses as displayed in the screenshot below. Both set of data have been marked in the screenshot below.

Get-NetIPconfiguration to get network interface alias

We can see from the screenshot above that the network interface alias that we want to work with is Wi-Fi 2 and the current DNS server address is We will add a new DNS server address of to the existing DNS server address by using the command below.

Set a new DNS address

To set a new DNS server, we will use the following command:

Set-DnsClientServerAddress -InterfaceAlias “Wi-Fi 2” -ServerAddresses (“,”)

This command adds a new DNS server address of to the existing DNS server address of Do note that we have to mention both DNS servers as part of the command. If we were to use one of these addresses, only one DNS server will be added to the network interface configuration.

Now that we have assigned two DNS servers to the network interface with network interface alias ‘Wi-Fi 2’, we will validate the DNS configuration. We can do so by using the Get-NetIPConfiguration command once again.


From the subsequent output of this Powershell command, we can see that the network interface alias ‘Wi-Fi 2’ has a couple of DNS server addresses as given below:


Both these DNS servers have been marked in the screenshot.

Get-NetIpConfiguration to find DNS server addresses


In this Powershell tutorial, we have seen how we could assign a DNS server address to a specific network card. We could also remove the already configured DNS server address. For this tutorial, we have used the following Powershell commands:

  • Get-NetIpConfiguration
  • Set-DnsClientServerAddress

Suggested Powershell Tutorials

The Powershell tutorials shared below help in performing basic Windows tasks using Powershell cmdlets and directives. You may like to read these instructions.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Rajesh Dhawan

Rajesh Dhawan is a technology professional who loves to blog about smart wearables, Cloud computing and Microsoft technologies. He loves to break complex problems into manageable chunks of meaningful information.