How to change Windows 10 DNS from PowerShell

The easiest way to connect to a network without having to configure anything is to use DHCP, the dynamic host configuration protocol that automatically gives computers an IP configuration when they connect to the network. If you do not have a DHCP server or want to apply a specific configuration to the computers, you must manually configure the IP and DNS in the most convenient way in your operating systems.

Windows 10 DNS, How to change Windows 10 DNS from PowerShell, Optocrypto

The default way to change the IP and DNS in Windows is directly from the TCP/IPv4 protocol properties of the network card, through the window, which will surely be very familiar.

Change Windows IP

Although this is the typical and easiest way if we often change DNS, or if we want to configure more than the two DNS that Windows allows us, we can make it much faster by executing a simple command and even creating a script that, if double-clicked on a script will do the job.

Here’s how to do that.

To change the DNS of a network card in Windows 10 from PowerShell

To do this, we must first open a PowerShell window with administrator rights. To do this, we search for “PowerShell” in Cortana and right-click to open this console with administrator rights. Once inside, you must first recognize the name of the network card for which you want to change the DNS. To do this, we execute the following command:

Get-NetAdapter -physical | where the status is -eq ‘up’.
Note the name in the “Name” column, as it is the name you need to use. Once the network card is identified, the next step is to run the command to change the DNS. To do this, we change the values of our configuration for the DNS servers we want to apply to the network and run the following command:

set-DnsClientServerAddress -Ethernet interfaceAlias –

ServerAddresses 1.1.1.1.1.1,8.8.8.8.8.8,9.9.9.9.9,192.168.1.1

As soon as this command is executed, the DNS configuration of your network card has changed. Now we only have to execute the command “ipconfig -all” to see that the change has actually been made.

Changing DNS Windows 10 PowerShell

As we can see, this simple trick makes it very easy to change our computer’s DNS. If we already have some knowledge of PowerShell, we can simply create a script to switch from one DNS to another in seconds.