r/PowerShell • u/TheOneWhoKnocksBR • Jul 28 '22
Question Adding a GUI for Powershell scripts - Preferred and Easiest method
I had been looking for a way to add a GUI to my powershell scripts in the past and could not find one that was simple enough for me to get started.
I am aware normally its built using .NET but I think the learning curve on that would be a bit intense just to learn how to add some GUI to my scripts? If someone know any specifc training I would appreciate.
I know how to use Tkinter on Python, and have tried some parse powershell commands to python but the results were kind of messy and not really friendly.
Does anyone know what is the best, and what is the easiest option to go around learning how to add my scripts to a GUI format?
6
u/TheOneWhoKnocksBR Jul 28 '22
Thanks everyone for posting some interesting ways to get a GUI done on PowerShell. - I should deff get something work now finally!! - my team and I appreciate it :)
15
u/Gregor2c Jul 28 '22
This is one of the best series I have seen on building GUIs in PowerShell. The guy talks very slow, and that can be good, but if you have an intermediate level of PowerShell script building understanding, you might make good use of the playback speed.
https://youtu.be/jPhznpFna7E?list=PLnK11SQMNnE5_cl8n54h6OXNMnGl5Odtq
6
u/TheOneWhoKnocksBR Jul 28 '22
Thanks G! Ill doff have a look, its mostly for my team, to use the scripts I am doing as they would not be as familiar with the command line. Also it would be nice to see some scripts finished in some type of GUI application, "little pat on the back" I will give this a shot thanks
2
5
u/Fallingdamage Jul 28 '22
Looks like there are a lot of good resources here. Once you have a good GUI built and learn about adding Forms, Group Boxes, Radio Buttons, Buttons, Comboboxes, Checkboxes, Labels, Rich Text Boxes, etc - you can build and save some templates that you can always fall back on for examples. I still build all my GUIs in ISE since I have plenty of good code to work from.
1
2
u/gpearl-co Jul 28 '22
Look at the module any box. It was just update to work with posh7
1
u/TheOneWhoKnocksBR Jul 28 '22
any box
quickly look through the docs, and I think it will be the first option I will try, it looks somewhat simple enough for me to put something together in a day. Thanks for sharing G!
23
u/iminalotoftrouble Jul 28 '22
What are you trying to accomplish with a GUI? I've found myself saying this when I want to:
Add some human interaction to a script
read-host if I want the human to input some data
out-gridview -passthru if I want to manually select/parse options
Platform to invoke code with tweaks
pick a CI/CD tool to build/run your code. Azure DevOps is one of the more user friendly options imo, and comes with a lot of the extras
Enable others to run code to stop getting escalations
Consider building your own module and deploying it to their clients. Get people comfortable with running powershell commands, a little training goes a long way
An actual GUI might make sense
4
u/HeKis4 Jul 29 '22
read-host if I want the human to input some data
Mandatory parameters my dude. Depends on who will use your scripts and how but being able to enter parameters instead of having to do it manually rocks. Even if just because you'll have the entire call with parameters in your history.
If you need a custom prompt, you can go with a script block as the default value of the parameter which does more or less the same thing.
param ( [String] $myparam = read-host "myprompt" )3
u/iminalotoftrouble Jul 29 '22
lot of great ways to implement a user input workflow, and ^ should be pretty high up the list
13
u/Black_Magic100 Jul 28 '22
PowerShell Universal. I've used PoshGUI too and hated working with WPF. If you want web based, PowerShell Universal is AMAZING
2
Jul 28 '22
This 100%. Doesn’t even have to be web based as such, you can even create desktop apps with the tools Ironman software provide
2
u/Black_Magic100 Jul 28 '22
Oh yea I forgot about that. I think even PowerShell Universal has a desktop/PWA interface now
2
1
u/Alone-Movie4291 Mar 23 '26
Going to give it a go, I tried psh gui and found it a challenge. This sounds great.
1
8
u/EnergySmithe Jul 28 '22
Not free, but I am a long time fan of Sapien Powershell Studio for this purpose.
3
u/neztach Jul 28 '22
Any good online walkthrough you know that aren’t from 2012?
1
u/EnergySmithe Jul 28 '22
I have not looked recently, basically most things you could do in c# or vb.net Winforms works the same in Sapien Powershell studio but generates Powershell.
3
0
Jul 28 '22
[deleted]
3
u/EnergySmithe Jul 28 '22
I am honestly not sure, good question! I am not at work so cannot investigate right now. Most of the stuff I have done was just winforms based.
3
u/phony_sys_admin Jul 28 '22
Sadly it only does WinForms. There was talk a year or two ago about WPF integration, but nothing as of yet... At least it has PS7 support!
10
Jul 28 '22
I'm lazy and use PowerGUI. https://blog.ironmansoftware.com/using-powergui-with-powershell-5-and-7/
1
u/techierealtor Jul 29 '22
I tried power gui and was just having problems with it. One glaring flaw I found was I had a function with an if statement and it would cause the “fold code” to switch from just collapsing the function to collapsing everything. Opened the same script in ISE and worked perfectly.
1
Jul 29 '22
Ah yeah I just use the wysiwyg type functions to design the overall look then paste the code inside ISE and build the meat of it from there.
1
u/TheOneWhoKnocksBR Jul 31 '22
I have so far tried a few of the options recommended in the post, some i had tried in the past, others I had found a bit too hard for me to get my head around at the moment.
By far I have liked the AnyBox module the best.
It has been a bit tricky to understand how it works, but I think I got a good understanding of the main concept, so I will continuing messing with it for some time.
I am finished with a script idea I had in mind that I will be sharing with my colleagues, and will also be posting a link to the repository here.
Below is my first script using AnyBox, Its kind like a form to help you speed up the bulk,
block/unblock of accounts, password reset, removal and adding of licenses.
------------------------------------------------------------------------------------------------------
Thanks again everyone, I could not have done this without you, so to show my gratitude I am sharing the project here.
Here is a link for the Github if you want to check out the project
https://github.com/bazzofx/PowerShell-AnyBox-AdminDashBoard/blob/main/AdminDashBoard-AnyBox.ps1
5
u/OPconfused Jul 28 '22
The easiest GUI is to pipe an object to Out-GridView. It takes minimal reading to get up to speed on how to do this, and the implementation is as simple as working with a PS Object.
As a GUI, the functionality is very limited compared to more professional solutions, but the aesthetic is pleasing enough (imo) that it can still function fine for simple internal use-cases or covering certain ad-hoc scenarios.
4
u/SCCMAttempt Jul 28 '22
I found it very easy to use Visual Studio 2019 Community to create the UI itself,
it is mostly drag and drop, and it gives you the xaml code which can be used with powershell.
switching to xaml from .net reduced my UI design and implementation times drastically.
https://stackoverflow.com/questions/56134295/how-to-properly-import-xaml-code-to-powershell
3
u/RoyWaisbrot Jul 28 '22
I used PoshGUI before. It’s a VERT straightforward interface and very simple to implement in your code: https://poshgui.com/
BUT !! Whatever you use, MAKE SURE your code is not injected with malicious code while importing the GUI part to your application or or while implementing your code within the GUI code
5
2
Jul 28 '22
I was able to get something going mostly following this series. It shows creating a GUI using the Window Forms assembly early on, but switches to WPF on video 5. The leering curve isn't that steep, but it did require work on my end.
2
2
u/ericrobert Jul 28 '22
Haven't seen this one mentioned yet
1
u/Crizznik Oct 09 '25
I know you probably posted this earlier on or something, but it's really funny that from my view this is directly below another comment recommending PostGUI.
2
u/BlackV Jul 28 '22
the fastest and easiest method is to not do that, it makes your script faster and your life easier :)
That and out-gridview
2
u/Big_Oven8562 Jul 29 '22
Having spent a few years maintaining an in-house tool with a GUI, I second the notion that you should just not use a GUI if you can help it. If your tool is simple enough that it's easy to put together a GUI it probably doesn't need one. If it's complex enough that it could benefit from one then you should be doing a deep dive with something like this: https://www.foxdeploy.com/series/LearningGUIs
1
1
u/TheRealPanda69 Jul 28 '22
I just use a wpf frontend, and call the c# dll via powershell. It can run both c# and powershell logic
1
Jul 28 '22
Ive always worked in secure spaces with limited access to the internet or external tools and have had success using powershell form applications, its definitely not the easiest or the fastest, but its reliable and gets the job done for me.
1
Jul 29 '22
Sapien Powershell studio is the most powerful tool I’ve used for all things Powershell and has great GUI building templates and all.
1
u/foadsf Jul 29 '22
Not specifically PS related, but you can create "GUI"s using legacy Microsoft HTML Application (HTA) too.
1
u/dverbern Apr 13 '26
I'm 4 years late to respond to your comment, but I wanted to say that my first shot at GUI tools were exactly what you suggest - legacy HTA apps as a wrapper, which in my case contained VBScript.
1
0
u/UnfanClub Jul 28 '22
Probably not what you're looking for but I thought it's worth mentioning. Show-Command
0
Jul 28 '22
[deleted]
3
u/Black_Magic100 Jul 28 '22
As soon as I found PowerShell Universal I dropped poshgui. Two separate products, but man WPFs suck to work with.
0
Jul 28 '22
[deleted]
2
u/T_T0ps Jul 28 '22
Loved it when it was free, recently paid for it to help with a school project, and now I’m being charged monthly for it but my account shows I have no subscription so I cant unsubscribe.
2
u/nepronen Jul 29 '22
Hi T-T0ps
I have messaged you about your issue, I will get this sorted out asap
73
u/smarthomepursuits Jul 28 '22
This is what I use: https://smarthomepursuits.com/how-to-create-a-powershell-menu-gui/