Problem
You want to retrieve information about network adapters on a computer.
Solution
To retrieve information about network adapters on a computer, use the Win32_ NetworkAdapterConfiguration WMI class:
GetWmiObject Win32_NetworkAdapterConfiguration –Computer
PS >GetWmiObject Win32_NetworkAdapterConfiguration –Computer LEEDESK |
>> WhereObject { $_.IpEnabled }
>>
DHCPEnabled : True
IPAddress : {192.168.1.100}
DefaultIPGateway : {192.168.1.1}
DNSDomain : hsd1.wa.comcast.net.
ServiceName : USB_RNDIS
Description : Linksys WirelessG USB Network Adapter with SpeedBooste
r v2 Packet Scheduler Miniport
Index : 13
Discussion
The solution uses the Win32_NetworkAdapterConfiguration WMI class to retrieve information about network adapters on a given system. By default, PowerShell displays only the most important information about the network adapter but provides access to much more.
To see all information available, use the FormatList cmdlet, as shown in Example 247.
Example 247. Using the FormatList cmdlet to see detailed information about a network adapter
PS >$adapter = GetWmiObject Win32_NetworkAdapterConfiguration | >> WhereObject { $_.IpEnabled } >> PS >$adapter
Example 247. Using the FormatList cmdlet to see detailed information about a network adapter
DHCPEnabled : True IPAddress : {192.168.1.100} DefaultIPGateway : {192.168.1.1}
DNSDomain
: hsd1.wa.comcast.net.
ServiceName
: USB_RNDIS
Description
: Linksys WirelessG USB Network Adapter with SpeedBooste
r v2 Packet Scheduler Miniport
Index : 13
PS >$adapter | FormatList *
DHCPLeaseExpires Index Description
DHCPEnabled DHCPLeaseObtained DHCPServer DNSDomain DNSDomainSuffixSearchOrder DNSEnabledForWINSResolution DNSHostName DNSServerSearchOrder
: 20070521221927.000000420
: 13
: Linksys WirelessG USB Network Adapter with SpeedBooster v2 Packet Scheduler Minipor t
: True
: 20070520221927.000000420
: 192.168.1.1
: hsd1.wa.comcast.net.
:
: False
: LeeDesk
: {68.87.69.146, 68.87.85.98}
DomainDNSRegistrationEnabled : False
FullDNSRegistrationEnabled
: True
IPAddress
: {192.168.1.100}
IPConnectionMetric
: 25
IPEnabled
: True
IPFilterSecurityEnabled
: False
WINSEnableLMHostsLookup
: True
(...)
To retrieve specific properties, access as you would access properties on other PowerShell objects:
PS >$adapter.MacAddress 00:12:17:77:B4:EB
If you need dedicated infrastructure for managing and inspecting network adapter properties, consider a Turkey Dedicated Server for greater control over network configuration, adapter management, PowerShell administration, system monitoring, and Windows-based application workloads.