我正在尝试从远程主机获取BitLocker信息。我过去常常使用PowerShell (Get-BitLockerVolume)来做这件事,它可以提供很多有用的信息。当我尝试使用C#时,我得不到太多的信息。在Microsoft's网站和further research上,我找不到任何对我有帮助的东西。
有人知道如何在C#中获得与Get-BitLockerVolume相同的输出吗?
顺便说一下,这是我在C#中测试的内容:
CimSession session = CimSession.Create(computerHostName);
IEnumerable<CimInstance> GI1 = session.QueryInstances(@"root\cimv2\Security\MicrosoftVolumeEncryption", "WQL", "SELECT * FROM Win32_EncryptableVolume");
foreach(CimInstance i in GI1)
{
Console.WriteLine("MountPoint: {0}, Protection: {1}",
i.CimInstanceProperties["DriveLetter"].Value,
i.CimInstanceProperties["ProtectionStatus"].Value);
}发布于 2019-05-29 21:30:01
正如Jeroen回忆的那样,您将能够获得调用WMI实例上的方法的信息。至于文档,Win32_EncryptableVolume只公开了以下属性:
class Win32_EncryptableVolume
{
string DeviceID;
string PersistentVolumeID;
string DriveLetter;
uint32 ProtectionStatus;
};要使用WMI和方法访问轻松获取所需信息,您可以使用ORMi库:
例如,您可以这样定义您的类:
public class Win32_EncryptableVolume : WMIInstance
{
public string DeviceID {get; set;}
public string PersistentVolumeID {get; set;}
public string DriveLetter {get; set;}
public int ProtectionStatus {get; set;}
[WMIIgnore]
public int Version {get; set;}
public int GetVersion()
{
return WMIMethod.ExecuteMethod<int>(this)
}
}然后你可以这样做:
WmiHelper _helper = new WmiHelper("root\\Cimv2"); //Define the correct scope
List<Win32_EncryptableVolume> volumes = _helper.Query<Win32_EncryptableVolume>().ToList();
foreach(Win32_EncryptableVolume v in volumes)
{
v.Version = v.GetVersion();
}https://stackoverflow.com/questions/56360904
复制相似问题