Sign in to follow this  
Followers 0
blumi

How to handle Poweshell result with autoit

6 posts in this topic

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)

 

Share this post


Link to post
Share on other sites



This is because $X is not an array:

Runwait Return Value:

Success: Returns the exit code of the program that was run.

Share this post


Link to post
Share on other sites

Okay, how to save the poweshell result into an array or string?

Share this post


Link to post
Share on other sites

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 )

 

Share this post


Link to post
Share on other sites

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)

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0