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:

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.

This script can be deployed by SCCM as a package or an application, for which you can use this application detection method.

9 thoughts on “How to Set DNS Suffix and Registration using PowerShell

  1. Pingback: SCCM Application Detection Method for Network Adapter Configuration | BorisKagan.net

  2. Greg

    Works perfect, thanks so much! Was looking for days to find a way to do this. Most other tutorials just show how to set the “Append these DNS suffixes” list.

    Reply
  3. René Lodder

    Using Pure Powershell (5.0?), you can do:

    Get-NetAdapter -Name “name_of_your_adapter” | Set-DnsClient -UseSuffixWhenRegistering $false
    Get-NetAdapter -Name “name_of_your_adaptger” | Set-DnsClient -RegisterThisConnectionsAddress $false

    Instead of -Name, you could use -InterfaceIndex too

    To get the list of interfaces, use:

    Get-NetAdapter

    Reply
  4. Joe

    Keep in mind you need to run PowerShell in admin mode. If you do not you will get a 91/90 code witch means it did not work. You should be looking for a Code 0. Worked like a charm. Thank you

    Reply
  5. Shawn

    Is it possible to apply this command to all network adapters or individually named network adapters rather than the one currently pulling ip?

    Reply
  6. l0wk33y5

    This is great working little script, no issues when implemented correctly. However, I have massive a deployment projects, which requires each Network Adapter to have the same settings applied, regardless if the adapter is connected/live with an IP-Address. How would I go about having the other adapters configured exactly the same, even though they’re “Not Connected/No Connection”?

    Reply
  7. Dave Wheats

    Nice script. What is the command to set “append primary and connection specific DNS suffixes” radio button and the check box “append parent suffixes of the primary DNS suffix.”?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.