Envin
Envin

Reputation: 1523

Need to check if IPv6 is disable on default Network adapter (or all of them) for Windows Server 2008

I have a requirement to check to see if IPv6 is disabled on a server. My script can't enable or disable it, just check.

I made this post a while back VBScript subroutine to check IPv6 status in registry...returning -1 and I've been using this logic and it has been working fine. Today I came across an issue where I was getting a false negative. The IPv6 checkbox on the adapter was unchecked and the logic of my code (in the link I pasted) doesn't check for that, the "DisabledComponents" key wasn't even present.

I've been searching for a few hours and can not find ANY way of knowing whether or not the default network adapter has IPv6 enabled. I would be fine iterating through all the network adapters but there isn't a property in WMI Network Adapters to tell me if IPv6 is enabled.

I'm at a loss unfortunately...

Any suggestions?

P.S. My code is in the link

EDIT: Output from Rene's solutions

    SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\ no disabled components

    \Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}  = \Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}
    \Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}  = \Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}
    \Device\{F2E73C76-C023-492D-8A14-824233F953F9}  = \Device\{F2E73C76-C023-492D-8A14-824233F953F9}
    \Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}  = \Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}
    \Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}  = \Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}
    \Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}  = \Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}
    \Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}  = \Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}
    \Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}  = \Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}
\Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}
\Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}
\Device\{F2E73C76-C023-492D-8A14-824233F953F9} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{F2E73C76-C023-492D-8A14-824233F953F9}
\Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}
\Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}
\Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}
\Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}
\Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}
\Device\{9E85E61A-EBB4-40E0-BB55-31FE48973DD2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{9E85E61A-EBB4-40E0-BB55-31FE48973DD2}
\Device\{4E0B9F15-E1C9-4093-A929-419BE1B089FB} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{4E0B9F15-E1C9-4093-A929-419BE1B089FB}
\Device\{4974F3E4-7493-428A-8DD4-3A43F64ACA00} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{4974F3E4-7493-428A-8DD4-3A43F64ACA00}
\Device\{C6E0B4F3-BC2C-49D7-9178-41F6F9C75C94} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{C6E0B4F3-BC2C-49D7-9178-41F6F9C75C94}
\Device\{8BE42170-83DC-4A40-880A-3163A88D8540} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8BE42170-83DC-4A40-880A-3163A88D8540}
\Device\{8EBA3452-69B1-4284-A859-58B9C3A2735B} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8EBA3452-69B1-4284-A859-58B9C3A2735B}
\Device\{046E21CF-38BB-447B-81F1-12536E4260DE} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{046E21CF-38BB-447B-81F1-12536E4260DE}
\Device\{FB30DEEC-3A32-47FF-A8CC-EBFB112D29C2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{FB30DEEC-3A32-47FF-A8CC-EBFB112D29C2}
\Device\{72A0EBC4-11EE-4A57-8F4E-9771264B7C74} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{72A0EBC4-11EE-4A57-8F4E-9771264B7C74}
\Device\{767698C6-D554-4EFF-8D15-9F2F6BDA5FD3} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{767698C6-D554-4EFF-8D15-9F2F6BDA5FD3}
\Device\{CE60A593-435C-40C3-8D2D-F48D00F743B6} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{CE60A593-435C-40C3-8D2D-F48D00F743B6}
    ...

It includes more but I only pasted a snippet.

Upvotes: 1

Views: 3641

Answers (1)

rene
rene

Reputation: 42494

adapted the script from here and using this kb article as source. The script enumerates the Values to check first if DisabledComponents is found, it it is it echo's its content. If it is never found it echo's that no value was found (which basically means: all enabled)

'**************************************************************************
'IP Address Configuration: Check if ipv6 is disabled
'**************************************************************************
Sub CheckIPV6()
   WScript.Echo("Check if IPv6 is disabled")
   WScript.Echo("------------------------------------")
   Const strIPV6Key = "SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\"
   strValueName = "DisabledComponents"
   Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
   objRegistry.EnumValues HKEY_LOCAL_MACHINE, strIPV6Key, arrValueNames, arrTypes
   IPv6Disabled = false
   For I=0 To UBound(arrValueNames)
      IF arrValuesNames(I) = strValueName THEN
         objRegistry.GetDWORDValue HKEY_LOCAL_MACHINE, strIPV6Key,strValueName,strIPV6Status
         WScript.Echo(strIPV6Key & strValueName & " = " & strIPV6Status & vbCrLf)
         IPv6Disabled = true
      END IF
   NEXT
   IF NOT IPv6Disabled THEN
          WScript.Echo(strIPV6Key & " no disabled components" & vbCrLf)
   END IF

   Set objWMIService = GetObject(_
          "winmgmts:\\" & strComputer & "\root\cimv2")
   Set colNics = objWMIService.ExecQuery _
           ("Select * From Win32_NetworkAdapter ")


    objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, _
          "SYSTEM\CurrentControlSet\services\Tcpip6\Linkage", _
          "Bind",bindValues

   For Each objNic in colNics
        For Each strValue In bindValues
          REM DEBUG to see what values are read
          WScript.echo strValue & " " & objNic.GUID & " = " & Cstr( objNic.GUID = strValue)
        Next
   Next

End Sub

WIN32_NetworkAdapter by wmi
Multistring registry read

Upvotes: 1

Related Questions