Main example
List instances
# All instances of Win32_NetworkAdapter, with the main properties
Get-CimInstance -ClassName Win32_NetworkAdapter |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'InstallDate'
'MACAddress'
'ServiceName'
)Examples
Filter with WQL
# WQL filter evaluated by the provider: AdapterTypeID = 4 (LocalTalk)
Get-CimInstance -ClassName Win32_NetworkAdapter -Filter 'AdapterTypeID = 4' |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'InstallDate'
'MACAddress'
'ServiceName'
)The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.
Decode numeric values
# Lookup table for AdapterTypeID (values documented by Microsoft)
$adapterTypeIDName = @{
0 = 'Ethernet 802.3'
1 = 'Token Ring 802.5'
2 = 'Fiber Distributed Data Interface (FDDI)'
3 = 'Wide Area Network (WAN)'
4 = 'LocalTalk'
5 = 'Ethernet using DIX header format'
6 = 'ARCNET'
7 = 'ARCNET (878.2)'
8 = 'ATM'
9 = 'Wireless'
10 = 'Infrared Wireless'
11 = 'Bpc'
12 = 'CoWan'
13 = '1394'
}
# Lookup table for Availability (values documented by Microsoft)
$availabilityName = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
Get-CimInstance -ClassName Win32_NetworkAdapter |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'InstallDate'
'MACAddress'
'ServiceName'
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName Win32_NetworkAdapter |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'InstallDate'
'MACAddress'
'ServiceName'
)
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_NetworkAdapter
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, Flags
# Methods of the class
$cimClass.CimClassMethods |
Select-Object -Property Name, ReturnTypeProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AdapterType# | string | read | Network medium in use. The network adapters are as follows: Values (14)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AdapterTypeID# | uint16 | read | Network medium in use. Returns the same information as the AdapterType property, except that the information is in the form of an integer. Values (14)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AutoSense# | boolean | read | If True, the network adapter can automatically determine the speed of the attached or network media. This property has not been implemented yet. It returns a NULL value by default. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Availability# | uint16 | read | Availability and status of the device. Values (21)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Caption# | string | read | Short description of the object—a one-line string. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ConfigManagerErrorCode# | uint32 | read | Windows Configuration Manager error code. Values (32)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ConfigManagerUserConfig# | boolean | read | If True, the device is using a user-defined configuration. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreationClassName# key | string | read | Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description# | string | read | Description of the object. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DeviceID# key | string | read | Unique identifier of the network adapter from other devices on the system. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ErrorCleared# | boolean | read | If True, the error reported in LastErrorCode is now cleared. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ErrorDescription# | string | read | More information about the error recorded in LastErrorCode, and information about any corrective actions that may be taken. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GUID# | string | read | Globally unique identifier for the connection. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Index# | uint32 | read | Index number of the network adapter, stored in the system registry. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InstallDate# | datetime | read | Date and time the object was installed. This property does not need a value to indicate that the object is installed. This property has not been implemented yet. It returns a NULL value by default. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Installed# | boolean | read | If True, the network adapter is installed in the system. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InterfaceIndex# | uint32 | read | Index value that uniquely identifies the local network interface. The value in this property is the same as the value in the InterfaceIndex property in the instance of Win32_IP4RouteTable that represents the network interface in the route table. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LastErrorCode# | uint32 | read | Last error code reported by the logical device. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MACAddress# | string | read | Media access control address for this network adapter. A MAC address is a unique 48-bit number assigned to the network adapter by the manufacturer. It uniquely identifies this network adapter and is used for mapping TCP/IP network communications. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manufacturer# | string | read | Name of the network adapter's manufacturer. Example: "3COM" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxNumberControlled# | uint32 | read | Maximum number of directly addressable ports supported by this network adapter. A value of 0 (zero) should be used if the number is unknown. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxSpeed# | uint64 | read | Maximum speed, in bits per second, for the network adapter. This property has not been implemented yet. It returns a NULL value by default. For more information about using uint64 values in scripts, see Scripting in WMI). Unit: bits per second Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name# | string | read | Label by which the object is known. When subclassed, the property can be overridden to be a key property. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetConnectionID# | string | read/write | Name of the network connection as it appears in the Network Connections Control Panel program. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetConnectionStatus# | uint16 | read | State of the network adapter connection to the network. Values (14)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetEnabled# | boolean | read | Indicates whether the adapter is enabled or not. If True, the adapter is enabled. You can enable or disable the NIC by using the Enable and Disable methods. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NetworkAddresses# | string[] | read | Array of network addresses for an adapter. This property has not been implemented yet. It returns a NULL value by default. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PermanentAddress# | string | read | Network address hard-coded into an adapter. This hard-coded address may be changed by firmware upgrade or software configuration. If so, this field should be updated when the change is made. The property should be left blank if no hard-coded address exists for the network adapter. This property has not been implemented yet. It returns a NULL value by default. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PhysicalAdapter# | boolean | read | Indicates whether the adapter is a physical or a logical adapter. If True, the adapter is physical. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PNPDeviceID# | string | read | Windows Plug and Play device identifier of the logical device. Example: "*PNP030b" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PowerManagementCapabilities# | uint16[] | read | Array of the specific power-related capabilities of a logical device. Values (8)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PowerManagementSupported# | boolean | read | If True, the device can be power-managed (can be put into suspend mode, and so on). The property does not indicate that power management features are currently enabled, only that the logical device is capable of power management. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ProductName# | string | read | Product name of the network adapter. Example: "Fast EtherLink XL" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ServiceName# | string | read | Service name of the network adapter. This name is usually shorter than the full product name. Example: "Elnkii" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Speed# | uint64 | read | Estimate of the current bandwidth in bits per second. For endpoints which vary in bandwidth or for those where no accurate estimation can be made, this property should contain the nominal bandwidth. For more information about using uint64 values in scripts, see Scripting in WMI). Unit: bits per second Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Status# | string | read | Current status of the object. This property is inherited from CIM_ManagedSystemElement. Values include the following: Values (12)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StatusInfo# | uint16 | read | State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used. Values (5)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemCreationClassName# key | string | read | Value of the scoping computer's CreationClassName property. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemName# key | string | read | Name of the scoping system. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TimeOfLastReset# | datetime | read | Date and time the network adapter was last reset. Code |
Methods
Disable #
Disables the network adapter.
uint32 Disable();Call the Disable method
review before running# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "DeviceID = 'Example'"
$methodParameters = @{
InputObject = $instance
MethodName = 'Disable'
WhatIf = $true # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters
# With -WhatIf nothing runs and no result is returned
if ($result) {
$result.ReturnValue
}This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.
Enable #
Enables the network adapter.
uint32 Enable();Call the Enable method
review before running# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "DeviceID = 'Example'"
$methodParameters = @{
InputObject = $instance
MethodName = 'Enable'
WhatIf = $true # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters
# With -WhatIf nothing runs and no result is returned
if ($result) {
$result.ReturnValue
}This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.
Declared but not implemented methods: Reset, SetPowerState.
Remarks
The Win32_NetworkAdapter class is derived from CIM_NetworkAdapter.
The following list describes the Associator classes for Win32_NetworkAdapter:
- Win32_PnPEntity
- Win32_ComputerSystem
- Win32_NetworkAdapterConfiguration
- Win32_IRQResource
- Win32_DeviceMemoryAddress
- Win32_PortResource
- Win32_NetworkProtocol
- Win32_SystemDriver
Many systems have a number of network adapters on them. Consider using the following as a reference to find the current adapters:
``` syntax
AdapterType: "Ethernet 802.3"
MACAddress: String Length > 16
Availability: 3
PNPDeviceID: InStr ( PNPDeviceID, "PCI") = 1
Installed: vbTrue
ConfigManagerErrorCode: 0
: <keep this as an index to Win32_NetworkAdapterConfiguration>
```
Even using the above qualifiers, you will likely retrieve more than one valid network adapter. If that is the case, Then you can use the following information to further qualify your search of the Win32_NetworkAdapterConfiguration:
``` syntax
Index: <match to DeviceID above>
MACAddress: Length > 16
DefaultIPGateway: String Length > 6
DNSServerSearchOrder: Array of strings with length > 6
IPEnabled: vbTrue
IPAddress: Array of strings with length > 6
```
Once you have done so, you will likely have reduced your list to one or two configured adapters.
You can also use the following procedure to find the default adapter:
1. Run the following query:
"SELECT InterfaceIndex, Destination FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'"
You should only have one default network destination 0.0.0.0.
2. Use the InterfaceIndex to retrieve the Network Adapter you want.
"SELECT * FROM Win32_NetworkAdapter WHERE InterfaceIndex=" + insertVariableHere
Inheritance
Superclass chain
- CIM_ManagedSystemElement
- CIM_LogicalElement
- CIM_LogicalDevice
- CIM_NetworkAdapter
- Win32_NetworkAdapter
Known subclasses
No known subclass.
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- Provider
- CIMWin32
- MOF file
- CIMWin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
Dynamic Provider("CIMWin32") UUID("{8502C4C0-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.