Jump to content

Run powershell script in autoit and get object return


Recommended Posts

I want to run a command/script over Powershell via autoit and work with the return object.
The background is that i want to check a lot of regkeys, wmi values on around 100 clients, which is now running one by one and takes like forever.

So i want to use New-PSSession & Invoke-command to run the script on 100 clients at once and get the results very fast.
Executing a powershell script from autoit is no big deal, but i don't know how to get an object return to work with it in Autoit.

I already had a look at the .NET Common Language Runtime (CLR) Framework but i didn't figured out how to get a return from the poweshell execute.
Of course a workaround would be to write the return from the powershell script to a file locally and read them with autoit,
but i would prefer any other solution without using the filesystem in between and converting object to sting and string to array.

Is there any way to do this?
Thanks a lot

Link to comment
Share on other sites

  • Moderators

First question I would have is, what is the compelling reason to mix AutoIt and PowerShell? Best practice is to not mix languages unless you must. In this case, what is PowerShell unable to do that you are using AutoIt for?

Edited by JLogan3o13

"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

3 hours ago, devilman16 said:

....
The background is that i want to check a lot of regkeys, wmi values on around 100 clients, which is now running one by one and takes like forever.

So i want to use New-PSSession & Invoke-command to run the script on 100 clients at once and get the results very fast.

.....

Is there any way to do this?
 

you didn't say what commands you want to use and what data is returned, but I think you can try with this:
https://www.autoitscript.com/forum/topic/192157-multi-task-easily-run-and-mange-many-processes/

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

There are dozens of solutions on inter process communication in Autoit but as said above more info would be nice to understand the why you mix languages.

There are .NET integrations in the examples section but they can be hard to implement and are maybe to much overhead.

WMI querying should not be heard from AutoIt

VBScript example with minmgmts should be easy to transform to Autoit

strComputer = "Computer_B"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

Example if you search the forum for winmgmts

$objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & '\root\cimv2:Win32_LogicalDisk="C:"')
MsgBox(0, "TEST", "Free Diskspace on C: " & $objWMI.FreeSpace & " bytes / " & Round($objWMI.FreeSpace / 1024^2) & " mb")
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...