Search code examples
powershellwindows-server-2008wmiipv6

Disable IPV6 on specific NIC via PowerShell using a Com Object on Windows Server 2008 R2?


I need to script some Windows Server 2008 R2 builds, preferably in PowerShell. I need to disable or uncheck IPV6 on a specific NIC (the same NIC every time). Currently, I have to set it manually. I do not want to disable IPV6 completely for the entire server other things may use that in the future. Is there an object I can reference in a PowerShell command specifying my NIC "Intel(R) PRO/1000 MT Network Connection" and disable IPV6? Unfortunately, Group Policy is not an option says the boss. I've tried finding an appropriate WMI object via "PowerShell Scriptomatic" but failed to find the difference between an enabled setting versus disabled on the Intel NIC. Thanks in advance.


Solution

  • First before removing IPV6 you'better read these Microsoft articles :

    How to disable IP version 6 (IPv6)

    What are Microsoft's recommendations about disabling IPv6?

    In summary you can disable IPV6 on all interfaces using (detailled explanation here):

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters]
    “DisabledComponents”=dword:ffffffff
    

    Edited

    According to @David Brabant comment to desable IPV6 on only one adapter you can bind or unbind it with the registry key :

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip6\Linkage]
    "Bind"=RegmultiSZ
    

    of the form :

    \Device\{DBB82A20-A485-4CB6-AD31-EF14B91F5EFB}
    

    You can build this line with :

    # Public Name NetworkCard Name
    $networkCardName = "Connexion au réseau local 1"
    
    # Get Device GUID
    $guid=(gwmi -query "select * from win32_networkadapter where netconnectionid= '$networkCardName'").guid