How to Set DNS Suffix and Registration Using PowerShell

This very simple PowerShell script can be used to set these options:

  • DNS Suffix for this connection
  • Register this connection’s addresses in DNS
  • Use this connection’s DNS suffix in DNS registration

I’ve seen many questions online on how to use a script to mark the two checkboxes in this “Advanced TCP/IP Settings” window.

So here is the very short and simple PowerShell script:PowerShell

$networkConfig = Get-WmiObject Win32_NetworkAdapterConfiguration -filter “ipenabled = ‘true'”



ipconfig /registerdns

The first line gets the adapters with a valid IP address. The second line sets the “DNS suffix for this connection” field. The third line enables each of the two checkboxes – if you change one of the $true values to $false, it will uncheck the corresponding checkbox. Finally, the last line simply updates the new settings in DNS without the need to restart the machine or anything like that.