How to use WMI to query IP address from specific NIC?

5,054

How to use WMI to query IP address from specific NIC?

You need to select one property to make this specific and the correct, like: Description MAC Address IPAddress:

Get this from the command line and remove any unnecessary ones (in this example):

wmic nicconfig get macaddress,description|findstr /vb "Microsoft Bluetooth WAN Miniport"
  • In the output of the command, select the mac address already distinguishing which is Ethernet and which is Wi-Fi if applicable, if not, use the ‘interfaces’ that apply to your case:
Description                               MACAddress
Realtek PCIe GBE Family Controller        E1-4B-AF-9F-FE-D2
Intel(R) Dual Band Wireless-AC 3165       2C-04-0E-50-F0-E5
  • Add this each mac address accorded with this query in BGInfo:
IP ehernet: 
SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where MACAddress='E1-4B-AF-9F-FE-D2'

IP wireless:
SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where MACAddress='2C-04-0E-50-F0-E5'


enter image description here



  • Results:


enter image description here


Obs.: These are the devices removed for this example (the unnecessary ones):

wmic nicconfig get macaddress,description|findstr /vb "Microsoft Bluetooth WAN Miniport"

Microsoft Kernel Debug Network Adapter
Realtek PCIe GBE Family Controller
Intel(R) Dual Band Wireless-AC 3165
Microsoft Wi-Fi Direct Virtual Adapter
Bluetooth Device (Personal Area Network)
WAN Miniport (SSTP)
Microsoft Wi-Fi Direct Virtual Adapter
Apple Mobile Device Ethernet

Note: For purposes of illustration, I used the same mac address in both requests, which explains the same ip in both, also the mac address came from one fake mac address generate

Share:
5,054

Related videos on Youtube

Izzo
Author by

Izzo

Trying to add a little more kindness to the stack exchange community.

Updated on September 18, 2022

Comments

  • Izzo
    Izzo over 1 year

    I have a computer with two NICs. I'm trying to query the IP address of each NIC separately to use in BGInfo.

    This article describes how to query the IP address of only active network interfaces. It uses the following WMI query

    SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True
    

    However, I want to query each IP address separately by referencing the name of the NIC. I've tried the following query but it fails due to being invalid.

    SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE Name=""
    

    How do I use WMI to query the IP address of a specific NIC? There are few resources available.

  • Izzo
    Izzo over 3 years
    I'm getting an error: Query not in form "SELECT xxx FROM ...". Any idea as to why this would happen?