blumi Posted October 10, 2016 Posted October 10, 2016 How to handle the result from powershell with autoit. Thought the powershell result would be an array and tried _ArrayDisplay, but nothing happens. $x = RunWait ( @ComSpec & ' /k @powershell -c "Get-CimInstance -Namespace root/Microsoft/Windows/DeviceGuard -ClassName Win32_DeviceGuard"', @SystemDir ) _ArrayDisplay($x)
Juvigy Posted October 10, 2016 Posted October 10, 2016 This is because $X is not an array: Runwait Return Value: Success: Returns the exit code of the program that was run.
blumi Posted October 10, 2016 Author Posted October 10, 2016 Okay, how to save the poweshell result into an array or string?
Juvigy Posted October 10, 2016 Posted October 10, 2016 You can pipe the output of the CMD command to a file. Then you can read the file to get the results. $x = RunWait ( @ComSpec & ' /k @powershell -c "Get-CimInstance -Namespace root/Microsoft/Windows/DeviceGuard -ClassName Win32_DeviceGuard" > c:\logfile.txt ', @SystemDir )
Moderators JLogan3o13 Posted October 10, 2016 Moderators Posted October 10, 2016 Must it be in PS, since you're running it in AutoIt anyway? Natively, you would do something like this: #include <MsgBoxConstants.au3> Local $sString = "" Local $oWMI = ObjGet("winmgmts:\\.\root\Microsoft\Windows\DeviceGuard") Local $oItems = $oWMI.ExecQuery("SELECT * FROM Win32_DeviceGuard") For $sItem In $oItems For $sProperty In $sItem.Properties_ $sString &= $sProperty.Name & ": " & $sProperty.Value & @CRLF Next Next MsgBox($MB_SYSTEMMODAL, "DeviceGuard Class Names and Values", $sString) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
iamtheky Posted October 18, 2016 Posted October 18, 2016 (edited) I would pipe your powershell wmi queries through bash so you can 'cowsay | lolcat' the output to the console, and obfuscate the whole command just to be a dick about it. Edited October 18, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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