.vbs script that echo's the Bitlocker status of the C Drive

1

I am trying to create a .vbs script that will echo the BitLocker status of a computers C drive.

I tried using the following code but I got the error 0X80041003, Source: (null).

strComputer = "." 
Set objShell = CreateObject("Wscript.Shell") 
strEnvSysDrive = objShell.ExpandEnvironmentStrings("%SystemDrive%") 

Set objWMIServiceBit = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") 
Set colItems = objWMIServiceBit.ExecQuery("SELECT * FROM Win32_EncryptableVolume",,48) 

For Each objItem in colItems 
    If objItem.DriveLetter = strEnvSysDrive Then 
        strDeviceC = objItem.DeviceID 
        DriveC =  "Win32_EncryptableVolume.DeviceID='"&strDeviceC&"'" 
        Set objOutParams = objWMIServiceBit.ExecMethod(DriveC, "GetProtectionStatus") 
        If objOutParams.ProtectionStatus = "1" Then 
            wscript.Echo "Bitlocker is enabled" 
        Else 
            wscript.Echo "Bitlocker is disabled" 
        End if 
    End If 
Next

Does anyone know why I keep getting this error or have any .vbs script that will echo the BitLocker status of the C Drive?

vbscript
asked on Stack Overflow Sep 13, 2018 by Tom J • edited Sep 13, 2018 by Filburt

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0