1

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.

0

2 Answers 2

1

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

0

You can query like this to get the IP address of specific network adapter:

wmic path win32_networkadapterconfiguration where "IPEnabled=True" get caption,ipaddress | find /i "ADAPTER NAME"

For all adapters (with IP enabled):

wmic path win32_networkadapterconfiguration where "IPEnabled=True" get caption,ipaddress
1
  • I'm getting an error: Query not in form "SELECT xxx FROM ...". Any idea as to why this would happen?
    – Izzo
    Commented Oct 10, 2020 at 23:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .