How to list hardware and software information using IP addresses of all connected machines in local network.
I have fetched all my systems hardware and software information using WMI from console application. But i wanted to fetch all the systems connected to LAN network using IP-address. kindly check my below code and help me out to fetch all network systems.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher myVideoObject = new ManagementObjectSearcher("select * from Win32_VideoController"); //To get information about the GPU
foreach (ManagementObject obj in myVideoObject.Get())
{
Console.WriteLine("Name - " + obj["Name"]);
Console.WriteLine("Status - " + obj["Status"]);
Console.WriteLine("Caption - " + obj["Caption"]);
Console.WriteLine("DeviceID - " + obj["DeviceID"]);
Console.WriteLine("AdapterRAM - " + obj["AdapterRAM"]);
Console.WriteLine("AdapterDACType - " + obj["AdapterDACType"]);
Console.WriteLine("Monochrome - " + obj["Monochrome"]);
Console.WriteLine("InstalledDisplayDrivers - " + obj["InstalledDisplayDrivers"]);
Console.WriteLine("DriverVersion - " + obj["DriverVersion"]);
Console.WriteLine("VideoProcessor - " + obj["VideoProcessor"]);
Console.WriteLine("VideoArchitecture - " + obj["VideoArchitecture"]);
Console.WriteLine("VideoMemoryType - " + obj["VideoMemoryType"]);
}
DriveInfo[] allDrives = DriveInfo.GetDrives(); //To get the information about the installed drives on the Desktop
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" Drive type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(" Available space to current user:{0, 15} bytes", d.AvailableFreeSpace);
Console.WriteLine(" Total available space: {0, 15} bytes", d.TotalFreeSpace);
Console.WriteLine(" Total size of drive: {0, 15} bytes ", d.TotalSize);
Console.WriteLine(" Root directory: {0, 12}", d.RootDirectory);
}
}
ManagementObjectSearcher myProcessorObject = new ManagementObjectSearcher("select * from Win32_Processor"); //To get information about the CPU
foreach (ManagementObject obj in myProcessorObject.Get())
{
Console.WriteLine("Name - " + obj["Name"]);
Console.WriteLine("DeviceID - " + obj["DeviceID"]);
Console.WriteLine("Manufacturer - " + obj["Manufacturer"]);
Console.WriteLine("CurrentClockSpeed - " + obj["CurrentClockSpeed"]);
Console.WriteLine("Caption - " + obj["Caption"]);
Console.WriteLine("NumberOfCores - " + obj["NumberOfCores"]);
Console.WriteLine("NumberOfEnabledCore - " + obj["NumberOfEnabledCore"]);
Console.WriteLine("NumberOfLogicalProcessors - " + obj["NumberOfLogicalProcessors"]);
Console.WriteLine("Architecture - " + obj["Architecture"]);
Console.WriteLine("Family - " + obj["Family"]);
Console.WriteLine("ProcessorType - " + obj["ProcessorType"]);
Console.WriteLine("Characteristics - " + obj["Characteristics"]);
Console.WriteLine("AddressWidth - " + obj["AddressWidth"]);
}
ManagementObjectSearcher myOperativeSystemObject = new ManagementObjectSearcher("select * from Win32_OperatingSystem"); //To get information about the Operative System
foreach (ManagementObject obj in myOperativeSystemObject.Get())
{
Console.WriteLine("Caption - " + obj["Caption"]);
Console.WriteLine("WindowsDirectory - " + obj["WindowsDirectory"]);
Console.WriteLine("ProductType - " + obj["ProductType"]);
Console.WriteLine("SerialNumber - " + obj["SerialNumber"]);
Console.WriteLine("SystemDirectory - " + obj["SystemDirectory"]);
Console.WriteLine("CountryCode - " + obj["CountryCode"]);
Console.WriteLine("CurrentTimeZone - " + obj["CurrentTimeZone"]);
Console.WriteLine("EncryptionLevel - " + obj["EncryptionLevel"]);
Console.WriteLine("OSType - " + obj["OSType"]);
Console.WriteLine("Version - " + obj["Version"]);
}
ShowNetworkInterfaces(); //To get information about the network interface
ManagementObjectSearcher myPrinterObject = new ManagementObjectSearcher("select * from Win32_Printer"); //To get information about the audio devices (Printers)
foreach (ManagementObject obj in myPrinterObject.Get())
{
Console.WriteLine("Name - " + obj["Name"]);
Console.WriteLine("Network - " + obj["Network"]);
Console.WriteLine("Availability - " + obj["Availability"]);
Console.WriteLine("Is default printer - " + obj["Default"]);
Console.WriteLine("DeviceID - " + obj["DeviceID"]);
Console.WriteLine("Status - " + obj["Status"]);
Console.WriteLine(String.Empty.PadLeft(obj["Name"].ToString().Length, '='));
}
Console.ReadLine();
}
public static void ShowNetworkInterfaces() //To get information about the network interface
{
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
Console.WriteLine("Interface information for {0}.{1} ",
computerProperties.HostName, computerProperties.DomainName);
if (nics == null || nics.Length < 1)
{
Console.WriteLine(" No network interfaces found.");
return;
}
Console.WriteLine(" Number of interfaces .................... : {0}", nics.Length);
foreach (NetworkInterface adapter in nics)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
Console.WriteLine();
Console.WriteLine(adapter.Description);
Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, '='));
Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType);
Console.WriteLine(" Physical Address ........................ : {0}",
adapter.GetPhysicalAddress().ToString());
Console.WriteLine(" Operational status ...................... : {0}",
adapter.OperationalStatus);
string versions = "";
// Create a display string for the supported IP versions.
if (adapter.Supports(NetworkInterfaceComponent.IPv4))
{
versions = "IPv4";
}
if (adapter.Supports(NetworkInterfaceComponent.IPv6))
{
if (versions.Length > 0)
{
versions += " ";
}
versions += "IPv6";
}
Console.WriteLine(" IP version .............................. : {0}", versions);
//ShowIPAddresses(properties);
// The following information is not useful for loopback adapters.
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback)
{
continue;
}
Console.WriteLine(" DNS suffix .............................. : {0}",
properties.DnsSuffix);
string label;
if (adapter.Supports(NetworkInterfaceComponent.IPv4))
{
IPv4InterfaceProperties ipv4 = properties.GetIPv4Properties();
Console.WriteLine(" MTU...................................... : {0}", ipv4.Mtu);
if (ipv4.UsesWins)
{
IPAddressCollection winsServers = properties.WinsServersAddresses;
if (winsServers.Count > 0)
{
label = " WINS Servers ............................ :";
//ShowIPAddresses(label, winsServers);
}
}
}
Console.WriteLine(" DNS enabled ............................. : {0}",
properties.IsDnsEnabled);
Console.WriteLine(" Dynamically configured DNS .............. : {0}",
properties.IsDynamicDnsEnabled);
Console.WriteLine(" Receive Only ............................ : {0}",
adapter.IsReceiveOnly);
Console.WriteLine(" Multicast ............................... : {0}",
adapter.SupportsMulticast);
}
}
}
}