Detect If IPv6 is Enabled on Windows Machines

31,883

Solution 1

Actually, a colleague came up with a nice way of doing it - a little clunky but works. :)

$IPV6 = $false
$arrInterfaces = (Get-WmiObject -class Win32_NetworkAdapterConfiguration -filter "ipenabled = TRUE").IPAddress

foreach ($i in $arrInterfaces) {$IPV6 = $IPV6 -or $i.contains(":")}

write-host $IPV6

Solution 2

You can use the .NET way :

Write-Host 'OS Supports IPv6: ' $( [System.Net.Sockets.Socket]::OSSupportsIPv6 )

The property will be true if it is possible to create an IPv6 datagram socket. This property is also affected by the global machine.config file, so the IPv6 status may not always be accurate.

Edit: To test this on a remote machine, you can still use powershell, but it has to have powershell 2.0 installed, and WinRM enabled.

If those two conditions are true, then you can probably use Invoke-Command to do that.

Solution 3

Testing for IPv6 would usually be more complicated than a yes/no answer with XP you have,

  1. Is the "Microsoft TCP/IP version 6" network component installed.
  2. Is there an adapter has an IPv6 address - one would usually assume (1) implies (2).
  3. Whether an adapter has a global-scope IPv6, i.e. not just a link local fe80:: prefixed address or loopback interface, ::1.

Presumaly (1) can be found with a Powershell script as demonstrated by Microsoft:

http://gallery.technet.microsoft.com/ScriptCenter/en-us/c4eb1596-7ac9-4be7-a711-b43446a3e3df

Solution 4

If you want to specifically check that IPv6 is enabled and working, I'd say the best way would be to try and connect to a test host. That way, you won't just test some specific software setting, but you'll also find out so that all the routing configuration and everything around it works as it should.

Solution 5

This is what you didn't want to do, but it seems the best method, going over the output that netsh interface provides.

You may want to look here for what you're after. Your implementation would be simpler, but iterating over the netsh interface ipv6 show interfaces results is all you need, if you find interfaces, it's enabled somewhere, if you don't find any, it's not.

Share:
31,883
Ben Short
Author by

Ben Short

Updated on May 16, 2020

Comments

  • Ben Short
    Ben Short almost 4 years

    I am writing a powershell script that will act as a build compliance test for our servers. One of the things I need to do is detect if IPv6 networking has been disabled.

    WMI indicates that this information can be found in the IPAddress Property of Win32_NetworkAdapterConfiguration but can be both IPv6 or IPv4. This does not give me a "yes/no" answer I am hoping to find.

    Other caveats are that I would prefer not to scrape the details by accessing the registry directly, nor scrape from the output of a command such as ipconfig.

    Given our environment has a mix of 2003/2008 machines, can anyone think of a way to test for IPv6?

    Cheers

  • klumsy
    klumsy about 13 years
    I think that should should true in most cases even if certian adapters have it disabled?
  • jhclark
    jhclark about 9 years
    This solution is overly optimistic -- it will say if the OS in general supports it, but NOT if it is actually enabled on any adapter. See the solution below to determine the latter.
  • Kieran Walsh
    Kieran Walsh over 4 years
    I also need to check the same thing as OP and your solution may work, but there is no -ComputerName switch for Get-NetAdapterBinding which makes this command a pain to use in a script where you want to scan all computers.