Best method for adding a gui to an existing script.

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Tuxhedoh
Posts: 3
Last visit: Thu Feb 21, 2019 10:57 am

Best method for adding a gui to an existing script.

Post by Tuxhedoh »

So I'm digging into Powershell Studio and I have an existing script that requires quite a few parameters. I'd like to build a gui around it and build an executable, however I'm not really sure how best to go about adding a gui to an existing script. Has this been documented elsewhere? Is there a tutorial I'm missing that covers this topic?

Product, version and build: Using Studio 2015 Version 4.2.83
32 or 64 bit version of product: 64bit
Operating system: Windows 8.1 64bit
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Best method for adding a gui to an existing script.

Post by davidc »

I moved this topic to the PowerShell GUI forums so other can chime in.

This really depends on what you are converting to the GUI and what functionality you wish to surface.

I recommend look at the help links in this topic:

viewtopic.php?f=21&t=6451

Particularly these articles:

http://www.sapien.com/blog/2012/06/04/u ... istrators/

http://www.sapien.com/blog/2012/06/11/s ... e-dialogs/

David
David
SAPIEN Technologies, Inc.
User avatar
Tuxhedoh
Posts: 3
Last visit: Thu Feb 21, 2019 10:57 am

Re: Best method for adding a gui to an existing script.

Post by Tuxhedoh »

The script as called currently must be run from powershell as an admin, and accepts the following parameters:
Servertype - Remote or Production
Computername - Accepting any input
Logfile location - Accepts input
DBServer - DB1, db2, db3, or db4

I can run this on the cli by running - myscript.ps1 -servertype remote -computername Mycomputer -logfile c:\temp\logfile.txt -dbserver db1

I would like to create a gui to provide options for those parameters, I'm looking for details around the best way to build the gui around my existing script... and not so much which controls to use. https://www.sapien.com/blog/2012/06/11/ ... e-dialogs/ looks like it's going to get there, but is more high level.... and it looks to be the last in that series of posts.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Best method for adding a gui to an existing script.

Post by dan.potter »

Not knowing what your script actually does I really can't give an informed opinion other than keep ps1's and forms separate. You're only asking for a headaches if you do.

Generally I use notepad for ps1's as they're typically one-off management critical priority one decisions :D I make forms for other non-ps people to use my scripts.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Best method for adding a gui to an existing script.

Post by jvierra »

What is it you have in mind for selecting the values of the arguments? You need to design the form first. Calling a PS1 file is trivial once you know how the form will navigate.

There is no way that an y of us can tell you how to design that. If you ask specific questions we will try to answer them. Start designing your form and go from there.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked