Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PowerShell中获取特定网络信息_Powershell_Networking - Fatal编程技术网

在PowerShell中获取特定网络信息

在PowerShell中获取特定网络信息,powershell,networking,Powershell,Networking,我不确定这是我的错误,还是我的PowerShell运行不正常 get-netipconfiguration | where {$_.subnetmask} 我也不能在网上找到任何有效的例子。我甚至尝试使用WMI命令,但仍然无法工作。我有最新版本的PowerShell,以前也做过,但我以前的方法不起作用。目前,我正在使用它进行IPaddress抓取,效果非常好 $ipaddress = (Get-NetIPConfiguration).IPv4Address.IPAddres 这很好,但我似

我不确定这是我的错误,还是我的PowerShell运行不正常

get-netipconfiguration | where {$_.subnetmask} 
我也不能在网上找到任何有效的例子。我甚至尝试使用
WMI
命令,但仍然无法工作。我有最新版本的PowerShell,以前也做过,但我以前的方法不起作用。目前,我正在使用它进行
IPaddress
抓取,效果非常好

$ipaddress = (Get-NetIPConfiguration).IPv4Address.IPAddres

这很好,但我似乎不知道如何使用它来显示
DNS
子网掩码。我知道这可能是一个noob问题,但他们已经改变了一些东西,我正试图找到一种不需要太多代码的简单方法。感谢您的帮助

您可以使用WMI检索此信息:

Get-WmiObject Win32_NetworkAdapterConfiguration | 
   Where IPEnabled | 
   Select IPSubnet, DNSServerSearchOrder, IpAddress

WMI的问题是什么,它非常简单?您可以尝试使用wbemtest以获得更好的图片。