Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect If IPv6 is Enabled on Windows Machines

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

like image 506
Ben Short Avatar asked Jan 19 '26 03:01

Ben Short


1 Answers

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.

like image 173
Jérôme Laban Avatar answered Jan 21 '26 18:01

Jérôme Laban