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!

5

u/Ckarini Jul 09 '19

I do agree with you to an extent-I've written many PowerShell scripts and some modules, and I also like to make everything clear as possible. The specific use case came up for me when I was asked to create a set of tools for our Tier 1 Service Desk to use. I tried making a module for them, and was horrified with how they thought the syntax worked. Even with tight-grip hand holding. I think, while as unnatural as it may be, there can be uses for PowerShell apps to have a GUI interface. Thanks for the feedback, and thank you for reading.

2

u/lordicarus Jul 09 '19

Oh yea, there definitely are use cases for it, I'm just not a fan of it is all. I guess what it really comes down to is that if my tier 1 engineers weren't smart enough to follow documentation on how to execute a script, they would no longer be my tier 1 engineers. If they can't be trusted to run a few commands in the command line, then they shouldn't be trusted to be doing any kind of administrative task, GUI or otherwise.

4

u/sysiphean Jul 09 '19

if my tier 1 engineers weren't smart enough to follow documentation on how to execute a script, they would no longer be my tier 1 engineers.

Oh that we could control who our tier 1s (or 2s, or 3s...) are in most organizations.

2

u/Simon-is-IT Jul 09 '19

Yep. I'd be happy if our T1 or T2 even knew what PowerShell was...nevermind what a module is or the syntax for a command.