检测是否在Windows计算机上启用了IPv6 [英] Detect If IPv6 is Enabled on Windows Machines

查看:427
本文介绍了检测是否在Windows计算机上启用了IPv6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Powershell脚本,该脚本将用作我们服务器的构建合规性测试.我需要做的一件事是检测是否已禁用IPv6网络.

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指示可以在Win32_NetworkAdapterConfiguration的IPAddress属性中找到此信息,但可以是IPv6或IPv4.我没有找到我想要的答案.

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.

其他需要注意的是,我不希望直接访问注册表来抓取详细信息,也不希望从ipconfig之类的命令的输出中抓取信息.

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.

鉴于我们的环境中混合使用了2003/2008机器,那么有人能想到一种测试IPv6的方法吗?

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

欢呼

推荐答案

实际上,一位同事想出了一种不错的方法-有点笨拙但可以工作. :)

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

这篇关于检测是否在Windows计算机上启用了IPv6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆