none
Disable auto DNS registration in powershell for single NIC

Answers

  • Close but you missed a bit at the end.

    Try it like this:

    # get adapter configuration by adapter name (NetCOnnectionID)
    $na=Get-WMIObject Win32_NetworkAdapter -filter "NetConnectionID = 'LAN'"
    $config=$na.Getrelated('Win32_NetworkAdapterConfiguration')
    # display current settings for DNS registration
    $config|select DomainDNSRegistrationEnabled, FullDNSRegistrationEnabled
    # disable DNS registration
    $config|%{$_.SetDynamicDNSRegistration($false,$false)}

    There are two settings.  The second one is the one we usually have an issue with. 

    We can use GetRelated to pull a related class by name or use a query with 'Associators Of'


    ¯\_(ツ)_/¯

    Wednesday, November 28, 2012 7:52 PM

All replies

  • Hello.

    The win32_NetworkAdapterConfiguration does not have the name of the Network Connection as a property, but win32_NetworkAdapter does.  Since they both have the deviceID/Index number, you can find the adapters you need by querying NetworkAdapter first.

    $name = "Local Area Connection"
    $netcon = Get-WMIObject Win32_NetworkAdapter -filter "NetConnectionID = '$name'" -property NetConnectionID,DeviceID
    $DevID = $netcon.DeviceID
    $adapt = Get-WMIObject Win32_NetworkAdapter -filter "Index = '$devid'"
    $adapt.SetDynamicDNSRegistration($false)

    • Proposed as answer by Derek Hanson Wednesday, November 28, 2012 7:14 PM
    Wednesday, November 28, 2012 7:13 PM
  • Close but you missed a bit at the end.

    Try it like this:

    # get adapter configuration by adapter name (NetCOnnectionID)
    $na=Get-WMIObject Win32_NetworkAdapter -filter "NetConnectionID = 'LAN'"
    $config=$na.Getrelated('Win32_NetworkAdapterConfiguration')
    # display current settings for DNS registration
    $config|select DomainDNSRegistrationEnabled, FullDNSRegistrationEnabled
    # disable DNS registration
    $config|%{$_.SetDynamicDNSRegistration($false,$false)}

    There are two settings.  The second one is the one we usually have an issue with. 

    We can use GetRelated to pull a related class by name or use a query with 'Associators Of'


    ¯\_(ツ)_/¯

    Wednesday, November 28, 2012 7:52 PM