David Browne said:
Then do a seach on "wmi ip mac" and discover that that information is
under the Win32_NetworkAdapter class. And find the following snippet of
code
oops
strComputer = "."
Set objWMIService = GetObject(_
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter " _
& "Where NetConnectionID = " & _
"'Local Area Connection 2'")
For Each objItem in colItems
strMACAddress = objItem.MACAddress
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration")
For Each objItem in colItems
If objItem.MACAddress = strMACAddress Then
For Each strIPAddress in objItem.IPAddress
Wscript.Echo "IP Address: " & strIPAddress
Next
End If
Next
Which tells you the classes you will need to use. Aparently you need to use
Win32_NetworkAdapter to enumerate the nic's and then match each nic with its
Win32_NetworkAdapterConfiguration by matching the MAC address. In the
server explorer you need so fumble around and add an additional class (right
click on Management Classes, add class). And find
Win32_NetworkAdapterConfiguration under root\CIMV2\Network Adapter Settings.
Add managed wrappers for both classes, and then write:
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using csTest.ROOT.CIMV2;
namespace csTest
{
class Program
{
public static void Main(string[] args)
{
Dictionary<string,NetworkAdapterConfiguration> configs =
new Dictionary<string,NetworkAdapterConfiguration>();
foreach (NetworkAdapterConfiguration config in
NetworkAdapterConfiguration.GetInstances())
{
if (config.MACAddress != null)
{
configs.Add(config.MACAddress, config);
}
}
foreach (NetworkAdapter nic in NetworkAdapter.GetInstances())
{
Console.WriteLine(string.Format("NIC {0} MAC
{1}",nic.Name,nic.MACAddress));
if (nic.MACAddress != null)
{
NetworkAdapterConfiguration config = configs[nic.MACAddress];
string[] addresses = config.IPAddress;
if (addresses == null)
{
addresses = new string[0];
}
foreach (string ip in addresses)
{
Console.WriteLine(string.Format(" Address {0}",
config.IPAddress));
}
}
}
}
}
}
Piece of cake, huh

. But you can get to everything, I mean everything,
using WMI.
David