r/PowerShell • • Jul 07 '19

Tutorial on creating Powershell applications using Visual Studio

https://domruggeri.com/2019/07/06/creating-extensive-powershell-gui-applications-part-1/
197 Upvotes

29 comments sorted by

View all comments

19

u/StartingOverAccount Jul 07 '19 edited Jul 07 '19

OK so this is one those thing I've wondered about a few times. Why would anyone create a GUI using Powershell (for a production task)? I see these posts every once in a while in forums and it just doesn't make sense. This tutorial is with Visual Studio. If you have VS why not just use C# or (shudder) VB? You'll get a much nicer UI, built in error handling, mult-threading (if needed).

This is one of those things just because you can, should you.

(yeah I've setup a couple forms on PS just for the fun factor)

Edit: The wondering is more out of curiosity. I don't have strong opinions for or against it just there are better ways to create a UI

5

u/Ckarini Jul 07 '19

I've wondered this myself, when learning how to do this. I'm not too great with Visual Basic or C#, but I understand PowerShell. Login prompts, PowerShell-specific commands, APIs, these are all things I already know how to do in PowerShell, and not in other languages. So, my goal was to allow the other PowerShell scripters to create an application without learning a new programming language.

Also, there are many ways to set up and display the UI which can look just as nice as any C# form. And, I'll be covering Error-Handling in an upcoming article- when we convert this to an exe, the write-warning and write-error commands will do the work for us. And as for the multithreading, we can do that as well with Start-Job.

3

u/StartingOverAccount Jul 07 '19

Fair enough.
To clarify a bit I wasn't implying you can't do any of that in PS. Just the amount of effort required between PS and other languages to accomplish this task.

2

u/Ckarini Jul 07 '19

Yeah, these things may be easier to do in other languages, but I only know PowerShell, so that's what's easiest for me.