I am a WMI noob. I'm using BGInfo and have a device with 2 NICs. I'm trying to query the IP address of one of the NICs. I want to submit a query based on the name of the NIC.
However, I'm running into an issue where the IP address is stored in Win32_NetworkAdapterConfiguration and the NIC name is stored in Win32_NetworkAdapter.
I want to build a WMI query like the following:
SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE Win32_NetworkAdapter.Name="My NIC Name".
Is this possible?
For basic understanding, run (from an open
cmd
window) the following command linesand read the following documentation:
WMI
class relates a network adapter and its configuration settings.Then you can understand how works the following code snippet (if you use a real value for
_adapterName
instead of the My NIC Name placeholder):Finally, you can restrict above output to the
IPAddress=…
line as follows: