blumi Posted October 10, 2016 Share 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) Link to comment Share on other sites More sharing options...
Juvigy Posted October 10, 2016 Share 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. Link to comment Share on other sites More sharing options...
blumi Posted October 10, 2016 Author Share Posted October 10, 2016 Okay, how to save the poweshell result into an array or string? Link to comment Share on other sites More sharing options...
Juvigy Posted October 10, 2016 Share 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 ) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 10, 2016 Moderators Share 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! Link to comment Share on other sites More sharing options...
iamtheky Posted October 18, 2016 Share 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 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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