Jump to content
Sign in to follow this  

Output powershell file from GUI

Recommended Posts



I'm new to autoit but had a question regarding creating a powershell script from inputs from a GUI. SPecifically this would involve reading the status of a checkbox or radio button then converting that to a line of code to be entered into a single powershell script that is created when the user clicks a button. 


I already have my basic UI setup and configured I need to perform a GUIctrlread then statement for the individual boxes. 

Is there an example that I haven't located that shows this task? I know it must be simple but I'm just not seeing the how. 

Share this post

Link to post
Share on other sites

You've already pretty much answered your own question. You would use GUICTrlRead to get the value of your input controls, and then simply pipe this to your PowerShell command. Something like this:

#include <GUIConstantsEx.au3>

    $hGUI = GUICreate("Test", 300, 200)
    $inpPC = GUICtrlCreateInput("Enter PC", 10, 10, 280, 30)
    $btnGo = GUICtrlCreateButton("Execute", 10, 150, 70, 40)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Case $btnGo
                Run(@ComSpec & ' /k powershell.exe Get-ADComputer ' & GUICtrlRead($inpPC) & ' -Properties *')


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites

I'm wanting this to write this to a powershell script or create a powershell script not run it. Basically the GUI is a series of check boxes that if they check the box it will enter a line of powershell command into a script that will be created when they click the button. 

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