【问题标题】:Get wired MAC address from computer/server从计算机/服务器获取有线 MAC 地址
【发布时间】:2012-05-14 12:40:35
【问题描述】:

我正在考虑使用有线 MAC-adr 作为程序中的唯一值。所以我需要确定 MAC-adr 是有线的而不是无线的。

$mac = gwmi -computer $compname win32_NetworkAdapterConfiguration | select MACAddress

这是我开始的,但它给了我两个地址。 第一个是我想要的:00:00:11:11:22:22 最后一个是无线地址:00:1F:3C:8E:61:D8

我不能只排序:选择 -first 1。因为我不知道这会给我在其他计算机上带来什么.. 顺便说一句,这对 ipV6 和 ipV4 都有效吗?

【问题讨论】:

    标签: networking powershell mac-address


    【解决方案1】:

    试试这个方法:

    $mac = gwmi -computer $compname win32_NetworkAdapter | ? { $_.AdapterType -match "802.3" } |  select MACAddress
    

    如果有多个,您需要进行选择。

    【讨论】:

      【解决方案2】:

      尽量具体一些,例如:

      (gwmi win32_NetworkAdapter -computer $compname -filter "NetConnectionID='Local Area Connection'").MACAddress
      

      【讨论】:

        猜你喜欢
        • 2013-03-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多