PowerShell for Windows Admins

Aug 26 2010   1:09PM GMT

WMI and Network Adapters: 1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Network adapters are a fundamental part of our system – without them our networks grind to a halt because the machines can’t communicate. We have a good tool in ipconfig for looking at NIC information but we can extend this using PowerShell and WMI.

Let’s start by seeing what is available.

Get-WmiObject -List *network*

returns a bunch of classes

Win32_NetworkLoginProfile
Win32_NetworkAdapterConfiguration
Win32_NetworkAdapterSetting
CIM_NetworkAdapter
Win32_NetworkAdapter
Win32_NetworkConnection
Win32_NetworkProtocol
Win32_NetworkClient
Win32_SystemNetworkConnections

plus some classes that give us performance counters – we’ll leave them for later.

Looking at the list of classes we’ll start with Win32_NetworkAdapter

On my Windows 7 machine I get a total of 14 adapters returned – that’s not bad for a machine with one Ethernet port and one wireless NIC!!  Each adapter returns some of the following information

ServiceName
MACAddress
AdapterType
DeviceID
Name
NetworkAddresses
Speed

This is the default data.  We can see what else might be available

Get-WmiObject -Class Win32_NetworkAdapter | Get-Member

gives us the following properties

AdapterType
AdapterTypeId
AutoSense
Availability
Caption
ConfigManagerErrorCode
ConfigManagerUserConfig
CreationClassName
Description
DeviceID
ErrorCleared
ErrorDescription
GUID
Index
InstallDate
Installed
InterfaceIndex
LastErrorCode
MACAddress
Manufacturer
MaxNumberControlled
MaxSpeed
Name
NetConnectionID
NetConnectionStatus
NetEnabled
NetworkAddresses
PermanentAddress
PhysicalAdapter
PNPDeviceID
PowerManagementCapabilities
PowerManagementSupported
ProductName
ServiceName
Speed
Status
StatusInfo
SystemCreationClassName
SystemName
TimeOfLastReset

if we look at the NICs that have the NetEnabled property set to true we get

PS> Get-WmiObject -Class Win32_NetworkAdapter -Filter “NetEnabled=’$true’”

ServiceName      : NVENETFD
MACAddress       : 00:1F:16:63:F5:DF
AdapterType      : Ethernet 802.3
DeviceID         : 7
Name             : NVIDIA nForce 10/100/1000 Mbps Networking Controller
NetworkAddresses :
Speed            : 10000000

ServiceName      : athr
MACAddress       : 00:24:2B:2F:9C:A5
AdapterType      : Ethernet 802.3
DeviceID         : 11
Name             : Atheros AR5007 802.11b/g WiFi Adapter
NetworkAddresses :
Speed            : 54000000

Comparing this to ipconfig

PS> ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::6d95:b824:6a72:a0a9%12
   IPv4 Address. . . . . . . . . . . : 192.168.196.139
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.196.1

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::4547:ee51:7aac:521e%11
   IPv4 Address. . . . . . . . . . . : 10.10.54.202
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.{01F4E3B7-5F1F-40BD-8252-DCC3331891C1}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.{4DFBBD42-D7E9-49B8-9AD0-F5A644A94173}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

I’m going to leave the tunnel adapters for now and just concentrate on the enabled NICs. To get the full set of information for these NICs we use

Get-WmiObject -Class Win32_NetworkAdapter -Filter “NetEnabled=’$true’” | fl *

I’ll leave you to look at what we get from this command. Next time we’ll look at what we need from this to populate of ipconfig type report.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: