首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BitLocker值

BitLocker值
EN

Stack Overflow用户
提问于 2019-05-29 20:40:22
回答 1查看 470关注 0票数 1

我正在尝试从远程主机获取BitLocker信息。我过去常常使用PowerShell (Get-BitLockerVolume)来做这件事,它可以提供很多有用的信息。当我尝试使用C#时,我得不到太多的信息。在Microsoft's网站和further research上,我找不到任何对我有帮助的东西。

有人知道如何在C#中获得与Get-BitLockerVolume相同的输出吗?

顺便说一下,这是我在C#中测试的内容:

代码语言:javascript
复制
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);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-29 21:30:01

正如Jeroen回忆的那样,您将能够获得调用WMI实例上的方法的信息。至于文档,Win32_EncryptableVolume只公开了以下属性:

代码语言:javascript
复制
class Win32_EncryptableVolume
{
  string DeviceID;
  string PersistentVolumeID;
  string DriveLetter;
  uint32 ProtectionStatus;
};

要使用WMI和方法访问轻松获取所需信息,您可以使用ORMi库:

例如,您可以这样定义您的类:

代码语言:javascript
复制
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)
  }
}

然后你可以这样做:

代码语言:javascript
复制
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();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56360904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档