try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_BaseBoard");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_BaseBoard instance");

Console.WriteLine("");

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

if(queryObj["ConfigOptions"] == null)

Console.WriteLine("ConfigOptions: {0}", queryObj["ConfigOptions"]);

else

{

String[] arrConfigOptions = (String[])(queryObj["ConfigOptions"]);

foreach (String arrValue in arrConfigOptions)

{

Console.WriteLine("ConfigOptions: {0}", arrValue);

}

}

Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);

Console.WriteLine("Depth: {0}", queryObj["Depth"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("Height: {0}", queryObj["Height"]);

Console.WriteLine("HostingBoard: {0}", queryObj["HostingBoard"]);

Console.WriteLine("HotSwappable: {0}", queryObj["HotSwappable"]);

Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);

Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);

Console.WriteLine("Model: {0}", queryObj["Model"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("OtherIdentifyingInfo: {0}", queryObj["OtherIdentifyingInfo"]);

Console.WriteLine("PartNumber: {0}", queryObj["PartNumber"]);

Console.WriteLine("PoweredOn: {0}", queryObj["PoweredOn"]);

Console.WriteLine("Product: {0}", queryObj["Product"]);

Console.WriteLine("Removable: {0}", queryObj["Removable"]);

Console.WriteLine("Replaceable: {0}", queryObj["Replaceable"]);

Console.WriteLine("RequirementsDescription: {0}", queryObj["RequirementsDescription"]);

Console.WriteLine("RequiresDaughterBoard: {0}", queryObj["RequiresDaughterBoard"]);

Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);

Console.WriteLine("SKU: {0}", queryObj["SKU"]);

Console.WriteLine("SlotLayout: {0}", queryObj["SlotLayout"]);

Console.WriteLine("SpecialRequirements: {0}", queryObj["SpecialRequirements"]);

Console.WriteLine("Status: {0}", queryObj["Status"]);

Console.WriteLine("Tag: {0}", queryObj["Tag"]);

Console.WriteLine("Version: {0}", queryObj["Version"]);

Console.WriteLine("Weight: {0}", queryObj["Weight"]);

Console.WriteLine("Width: {0}", queryObj["Width"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

Advertisements