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'
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