I'm trying to get BitLocker information from a remote host. I used to do this using PowerShell (Get-BitLockerVolume) which would provide lots of useful information. When I try using C#, I don't get as much information back. Looking on Microsoft's website and from further research, I can't find anything to help me.
Does anyone know how to get the same output as Get-BitLockerVolume in C#?
By the way, this is what I've been testing within 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);
}
(Get-Command Get-BitLockerVolume).Module | Get-Module | Select Path
will point you directly to the source in this case. Looking at that (Get-BitLockerVolumeInternal
), you'll see it uses the same CIM class as you're using, but calls a few more methods to get some data directly as properties. You can either replicate that stuff, or go the easy way and use a PowerShell pipeline in C# to just callGet-BitLockerVolume
directly. – Jeroen Mostert