Reputation: 3280
I have a Powershell V2 script that is done and all dandy. I pass parameters to it via
myscript.ps1 -firstparameter Donald -secondparameter Duck
I would like to have a "kicker" or "launcher" window/gui that simply lets me pass the arguments. I've designed the GUI in PrimalForms but I can't figure out how to send the arguments to my script and launch it.
My questions are:
PS: As of now I do not need any interaction with the GUI after "OK" have been pressed. I have no problem seeing a Powershell window pop up and do all the work in its "ugly glory"..
All help/tips are GREATLY appreciated:)
Upvotes: 0
Views: 2414
Reputation: 52689
So in PrimalForms i'm imagining you create a few user input controls (textboxes, etc) and you have a button to click to launch your script with the parameters the user entered into your form input controls. If this is the case you would create an event handler for the button and add the code to call your script to the script block handler. If you are using the free community edition, on the right you will see at the top of the properties pane a lightning bolt icon. This will add the code templates linking scriptblocks to the various GUI events. Click on your button and find the OnClick event and double click in the text field to add the code template. When you copy the generated code you will see a script block created for your button. You can launch your script from there. You'll need to access the forms properties to get the data the user entered. Something like & .\MyScript -Param1 $form1.textbox1.text -Param2 $form1.textbox2.text
.
Upvotes: 1