Reputation: 532
In c# I'm using the following code the get the status of BitLocker. When i run the script is says: Management Exception was unhandled. Any ideas?
ManagementClass objectSearcher; List<string> BitLocker = new List<string>(); objectSearcher = new ManagementClass("Win32_EncryptableVolume"); foreach (var item in objectSearcher.GetInstances()) { try { BitLocker.Add(item["DeviceID"].ToString()); BitLocker.Add(item["ProtectionStatus"].ToString()); } catch { BitLocker.Add("Error, could not retrieve data. \n"); } }
Upvotes: 2
Views: 3859
Reputation: 111
I believe you need to set a path and scope first, for example:
var path = new ManagementPath(@"\ROOT\CIMV2\Security\MicrosoftVolumeEncryption") { ClassName = "Win32_EncryptableVolume" };
var scope = new ManagementScope(path);
path.Server = Environment.MachineName;
var objectSearcher = new ManagementClass(scope, path, new ObjectGetOptions());
Upvotes: 4