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_BIOS");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_BIOS instance");

Console.WriteLine("");

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

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

else

{

UInt16[] arrBiosCharacteristics = (UInt16[])(queryObj["BiosCharacteristics"]);

foreach (UInt16 arrValue in arrBiosCharacteristics)

{

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

}

}

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

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

else

{

String[] arrBIOSVersion = (String[])(queryObj["BIOSVersion"]);

foreach (String arrValue in arrBIOSVersion)

{

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

}

}

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

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

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

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

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

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

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

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

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

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

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

else

{

String[] arrListOfLanguages = (String[])(queryObj["ListOfLanguages"]);

foreach (String arrValue in arrListOfLanguages)

{

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

}

}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}

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