Would like to know the c# code to actually retrieve the IP type: Static or DHCP based on a list of devices I will enter.
Output to be viewed:
Device name: IP Address: MAC Address: Type: Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller NULL 00:00:F3:44:C6:00 DHCP Generic Marvell Yukon 88E8056 based Ethernet Controller 192.168.1.102 00:00:F3:44:D0:00 DHCP
ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objMOC = objMC.GetInstances();
txtLaunch.Text = ("Name\tIP Address\tMAC Address\tType" +"\r\n");
foreach (ManagementObject objMO in objMOC)
{
StringBuilder builder = new StringBuilder();
object o = objMO.GetPropertyValue("IPAddress");
object m = objMO.GetPropertyValue("MACAddress");
if (o != null || m != null)
{
builder.Append(objMO["Description"].ToString());
builder.Append("\t");
if (o != null)
builder.Append(((string[])(objMO["IPAddress"]))[0].ToString());
else
builder.Append("NULL");
builder.Append("\t");
builder.Append(m.ToString());
builder.Append("\t");
builder.Append(Convert.ToBoolean(objMO["DHCPEnabled"]) ? "DHCP" : "Static");
builder.Append("\r\n");
}
txtLaunch.Text = txtLaunch.Text + (builder.ToString());
This gave me 90% of what I am looking to achieve - the code worked out well. The next portion is to specify a device on the network to obtain the information remotely. I noticed the one comment below that stated this was impossible without WMI. This is certainly much closer than I was. I'm convinced this can be accomplished. I'm open to recommendations here.