You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MSFT_NetAdapter无MACAddress属性,Win32_NetworkAdapter已弃用,如何获取MAC地址?

Nice question! I remember being confused by this too when Microsoft deprecated Win32_NetworkAdapter in favor of the newer MSFT_NetAdapter classes. Let's clear this up:

获取MAC地址的正确方式(替代弃用的Win32_NetworkAdapter)

First off: MSFT_NetAdapter does not have a direct MACAddress property—that's the key source of confusion here. Microsoft split hardware-specific attributes (like MAC addresses) into a separate class to keep MSFT_NetAdapter focused on configuration and state. Here are the reliable ways to get the MAC address:

1. Query via CIM, linking MSFT_NetAdapter and MSFT_NetAdapterHardwareInfo

The MSFT_NetAdapter and MSFT_NetAdapterHardwareInfo classes are linked by the InstanceID property. You can use WQL or PowerShell's CIM cmdlets to join them and retrieve the MAC:

WQL Example

SELECT MSFT_NetAdapter.Name, MSFT_NetAdapterHardwareInfo.PermanentAddress
FROM MSFT_NetAdapter
JOIN MSFT_NetAdapterHardwareInfo
ON MSFT_NetAdapter.InstanceID = MSFT_NetAdapterHardwareInfo.InstanceID

PermanentAddress here maps directly to the MACAddress property from the old Win32_NetworkAdapter class—it's the physical, permanent MAC of the adapter.

PowerShell CIM Example

Get-CimInstance MSFT_NetAdapter | ForEach-Object {
    $hardwareDetails = Get-CimInstance MSFT_NetAdapterHardwareInfo -Filter "InstanceID='$($_.InstanceID)'"
    [PSCustomObject]@{
        AdapterName = $_.Name
        MACAddress = $hardwareDetails.PermanentAddress
    }
}

2. Use PowerShell's Get-NetAdapter Cmdlet (Simplest Option)

If you're working in PowerShell, this is the easiest path. The Get-NetAdapter cmdlet wraps the CIM class logic and exposes a direct MacAddress property:

Get-NetAdapter | Select-Object Name, MacAddress

This will output a clean list of all your adapters with their corresponding MAC addresses—no manual class joining required.

Why the Split?

Microsoft redesigned the network adapter CIM classes to separate concerns:

  • MSFT_NetAdapter handles adapter configuration (like IP settings, enabled state) and general state.
  • MSFT_NetAdapterHardwareInfo holds hardware-specific details (MAC address, firmware version, bus type).

This makes the classes more modular and easier to maintain.


内容的提问来源于stack exchange,提问作者ispiro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:42:23