0

我正在尝试编写一个脚本来检索我网络上远程主机的 NIC 卡信息。

这是我的查询:

$wmi_networkadapter = $obj->ExecQuery("Select * from Win32_NetworkAdapter WHERE NetConnectionID LIKE 'Local Area Connection'");

这是输出:

   foreach ($wmi_networkadapter as $wmi_call) {
        //Caption
        $Caption = $wmi_call->Caption;
        echo "<b>Caption:</b> $Caption<br>";

        //MACAddress
        $MACAddress = $wmi_call->MACAddress;
        echo "<b>MACAddress:</b> $MACAddress df<br>";                                       
    }

我可以获取 Mac 地址和标题(NIC 名称),但我不知道如何获取 IP 地址。谢谢!

4

2 回答 2

0

我没有任何专门使用 WMI 的经验,但是调用时会得到什么结果var_dump($wmi_call)

于 2013-02-15T21:41:02.093 回答
0

行。我能够获得这样做的IP地址。

使用此查询:

$wmi_networkadapter = $obj->ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPENabled = 'True'");

PHP:

foreach ($wmi_networkadapter as $wmi_call) {
    //Caption
    $Caption = $wmi_call->Caption;
    echo "<b>Caption:</b> $Caption<br>";

    //MACAddress
    $MACAddress = $wmi_call->MACAddress;
    echo "<b>MACAddress:</b> $MACAddress<br>";      

    //IP ADDRESS
    $ip = $wmi_call->IPAddress;
    foreach ($ip as $key => $value) {
     echo $value;
    }
}
于 2013-02-19T21:13:46.393 回答