r/PowerShell • • Jul 09 '19

Tutorial on creating PowerShell GUI Applications - Part 2

https://domruggeri.com/2019/07/09/creating-extensive-powershell-gui-applications-part-2/
132 Upvotes

17 comments sorted by

View all comments

5

u/Ckarini Jul 09 '19

Got a lot of positive feedback on the first article, so I decided to crank this one out. This time we take an in-depth look at Fields, and DataGridViews. If you guys have any suggestions on things you want to do in winforms with PowerShell, let me know!

1

u/lordicarus Jul 09 '19

I've never been a fan of building GUI for PowerShell, but this is really great stuff, keep it up.

In case you're curious, my feeling is that command line tools should stay command line tools. It's basically a sort of philosophical preference. The GUI you are building isn't going to work cross platform (most likely) and depending on things like screen DPI and some of the zoom settings in different versions of Windows, you may end up with things looking really messed up for one user. The command line keeps it all simple. My preference is to create comment based help for each of my more complicated scripts so that every parameter and parameter set is well known and easy to understand.

The most common complaint about GUI with PowerShell is "why not just write the code in VB/C# if you're already designing in VS. The problem with that PowerShell has a ton of modules that make connecting to different services very easy and it's nowhere near as easy, usually, to pull off the same stuff within C#/VB, even if you have more control that way. Sure, you could programmatically create a runspace from within VB/C# in your app that then receives commands based on UI interactions, but that adds even more complexity.

To my very first point, I may not be a huge fan of this, but this is a really good article and so was the first. Great work!

2

u/Reverent Jul 09 '19

I pretty much write this on every ps gui post, but this is why I write my guis in electron. It's cross platform (with PowerShell core), dpi friendly, and runs independently of the script. You just need to make up the script to take the right commands, and electron can gather up the parameters and run it for you.