LisHawj Posted July 10, 2018 Share Posted July 10, 2018 I am trying to retrieve the BitLocker protection status for drive C, and my script is reporting an error. What am I missing here? Thank you for your help. $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output = $Output & "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.DriveLetter = "C:" Then For $objPS In $objItem.ProtectionStatus $status = $objPS.ProtectionStatus Next EndIf Next EndIf MsgBox(0,"", "The ProtectionStatus is: " & status) Link to comment Share on other sites More sharing options...
water Posted July 10, 2018 Share Posted July 10, 2018 To help you we need further information. A good start would be to post the error message you get My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
LisHawj Posted July 10, 2018 Author Share Posted July 10, 2018 Thanks Water, it was late so I forgot about that. This is the error I am receiving. I do not understand the error code so am having problems fixing it. This is my first wade into WMI scripting with AutoIT. --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop"Y:\Scripting Workshop\WMI Object Scripts\Get BitLocker ProtectionStatus.au3" (15) : ==> Variable must be of type "Object".:For $objPS In $objItem.ProtectionStatus For $objPS In $objItem.ProtectionStatus^ ERROR ->07:34:56 AutoIt3.exe ended.rc:1 +>07:34:56 AutoIt3Wrapper Finished. >Exit code: 1 Time: 0.818 Link to comment Share on other sites More sharing options...
LisHawj Posted July 10, 2018 Author Share Posted July 10, 2018 Ok, after some rests I think I figure it out. I am now getting the value I expect to see, but expert eyes are still very much welcome. $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output = $Output & "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.DriveLetter = "C:" Then $objPS = $objItem.ProtectionStatus EndIf Next EndIf MsgBox(0,"", "The ProtectionStatus is: " & $objPS) Link to comment Share on other sites More sharing options...
spudw2k Posted July 11, 2018 Share Posted July 11, 2018 Looks like you got it. Just to provide a little explanation: $colItems returned from the WMI query (results) is a collection, which can be thought of like a series of records. Each record has what ever properties(/fields) were specified in the query, in this example all properties (*). There should be a "record" for each Drive, but you are only inspecting C:, which I'm sure you knew. You only have to enumerate (For .. In ..) a retrieved property in the collection if it is itself another type of collection (array)--for example the properties denoted with brackets ([]) on the Win32_NetworkAdapterConfiguration class MSDN page. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now