I have been asked on my post about How to get some information on Bitlocker using VBScript and WMI? if I could provide a solution using Visual Basic.
Here it is:
[code lang=”vb”]
Imports System.Management ‘Need to add System.Management reference to solution
Module Module1
Sub Main()
Dim arEncryptionMethod = {"None", "AES 128 With Diffuser", "AES 256 With Diffuser", "AES 128", "AES 256"}
Dim arProtectionStatus = {"Protection Off", "Protection On", "Protection Unknown"}
Dim arConversionStatus = {"Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"}
Dim arLockStatus = {"Unlocked", "Locked"}
Dim strComputer = "."
Dim colItems As New ManagementObjectSearcher("\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption", "SELECT * FROM Win32_EncryptableVolume")
For Each objItem As ManagementObject In colItems.Get()
Console.WriteLine("DeviceID: " & objItem("DeviceID"))
Console.WriteLine("DriveLetter: " & objItem("DriveLetter"))
Console.WriteLine(" EncryptionMethod: " & arEncryptionMethod(objItem.InvokeMethod("GetEncryptionMethod", Nothing, Nothing)("EncryptionMethod")))
Console.WriteLine(" ProtectionStatus: " & arProtectionStatus(objItem.InvokeMethod("GetProtectionStatus", Nothing, Nothing)("ProtectionStatus")))
Dim ConversionStatus As ManagementBaseObject = objItem.InvokeMethod("GetConversionStatus", Nothing, Nothing)
Console.WriteLine(" ConversionStatus: " & arConversionStatus(ConversionStatus("ConversionStatus")))
Console.WriteLine(" EncryptionPercentage: " & ConversionStatus("EncryptionPercentage") & "%")
Console.WriteLine(" LockStatus: " & arLockStatus(objItem.InvokeMethod("GetLockStatus", Nothing, Nothing)("LockStatus")))
Dim keyProtectors(1) As Object ‘[in, optional] uint32 KeyProtectorType, [out] string VolumeKeyProtectorID[]
keyProtectors(0) = 0 ‘Get all key protector types -> http://msdn.microsoft.com/en-us/library/windows/desktop/aa376441(v=vs.85).aspx
objItem.InvokeMethod("GetKeyProtectors", keyProtectors)
For Each keyProtector In keyProtectors(1)
Dim keyProtectorFriendlyName(1) As Object ‘[in] string VolumeKeyProtectorID, [out] string FriendlyName
keyProtectorFriendlyName(0) = keyProtector
objItem.InvokeMethod("GetKeyProtectorFriendlyName", keyProtectorFriendlyName)
Console.WriteLine(" KeyProtector: " & keyProtectorFriendlyName(1))
Next
Console.WriteLine()
Next objItem
End Sub
End Module
[/code]
Recent Comments