Syed23 Posted July 12, 2011 Share Posted July 12, 2011 (edited) Hi Friends, This is the first script i am trying to create COM. But i am facing some problem in OGJGET function. Could you please help me on that? For your reference i have my script below. Please let me know if i have posted my question in wrong forum. #RequireAdmin Global $objItem Dim $Output, $Output1, $arConversionStatus Dim $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "", 48) If IsObj($colItems) Then $Output = $objItem.GetProtectionStatus $Output1 = $objItem.GetConversionStatus If $Output = "Protection On" Then $arConversionStatus = "YES" Else $arConversionStatus = "NO" EndIf If $Output1 > 0 Then $arConversionStatus = "EncryptionPercentage" EndIf EndIf MsgBox(0, "", $arConversionStatus) Edited July 12, 2011 by Syed23 Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
wraithdu Posted July 12, 2011 Share Posted July 12, 2011 (edited) The problem is not with ObjGet, but your script errors. Your ExecQuery syntax was wrong, and you must use the For-In-Next syntax with an object collection. Try:SWbemServices.ExecQuery#RequireAdmin Global $objItem Dim $Output, $Output1, $arConversionStatus Dim $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", 48) If IsObj($colItems) Then For $objItem In $colItems $Output = $objItem.GetProtectionStatus $Output1 = $objItem.GetConversionStatus If $Output = "Protection On" Then $arConversionStatus = "YES" Else $arConversionStatus = "NO" EndIf If $Output1 > 0 Then $arConversionStatus = "EncryptionPercentage" EndIf ; exit loop here since there is presumably only one object ; if you are expecting more than one object from your query ; handle it appropriately ExitLoop Next EndIf MsgBox(0, "", $arConversionStatus) Edited July 12, 2011 by wraithdu Link to comment Share on other sites More sharing options...
Syed23 Posted July 12, 2011 Author Share Posted July 12, 2011 Thanks for quick reply and the script was working perfect! Thans a lot.. can you explain me how it works ? Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] 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