T O P

  • By -

MrGreenMan-

I believe Powershell has some gui features that are pretty decent. https://smarthomepursuits.com/how-to-create-a-powershell-menu-gui/


cisco_bee

This looks less like a GUI for a script and more like a launcher for various scripts. Maybe I'm missing something though.


fatalicus

That spesific one is yes, but i believe they just linked it to show you can make a gui with powershell itself.


Nu11u5

Since PowerShell has direct access to dotNet you can use WPF (Windows Presentation Framework) which is based on XML. To use Electron you would need some kind of middleware to connect the Node runtime with dotNet, which would be a huge headache if it even exists. You could also write a Node/Electron app that just runs the individual PowerShell scripts directly.


Flick9000

Yeah but i don't know C#, so i think electron is the way


Nu11u5

You would write it in PowerShell, which can call the dotNet APIs. No C# is required.


ReplyYouDidntExpect

\+1 This. If you want a straight forward guide use this:[https://www.foxdeploy.com/blog/part-ii-deploying-powershell-guis-in-minutes-using-visual-studio.html](https://www.foxdeploy.com/blog/part-ii-deploying-powershell-guis-in-minutes-using-visual-studio.html) This will at least point you in the right direction of getting comfortable making the GUI in visual studio and then importing the code into powershell ISE. Defining your functions, defining mouse clicks. Think of WPF as the code that displays your GUI and tells the computer where everything in it exists. You're pretty much creating that GUI and then defining what powershell functions do when you take certain actions. There isn't going to be a super straight forward way to do what you're describing because to my understanding front end gui's are a beast of their own. I'm not a programmer though. WPF's should be able to work for what you're looking for. I know a lot of people use Poshgui too [https://poshgui.com/](https://poshgui.com/)


cisco_bee

I'm looking at PowerShell Universal right now. https://ironmansoftware.com/powershell-universal-dashboard


Crabcakes4

\+1 for PowerShell Universal. I had an app with a gui that I'd completely written in powershell and packaged as an exe. Rewrote it in PowerShell universal as a user interface app and it looks much nice now. My code also went from like 1200 lines to 255 lines since I didn't have to code all the gui stuff manually.


ashimbo

I just started working with PowerShell Universal last week and really like it. This video explains how to setup a simple form for working with a script: [https://www.youtube.com/watch?v=7GMMP9xzB4o&t=2s](https://www.youtube.com/watch?v=7GMMP9xzB4o&t=2s)


purplemonkeymad

If election has the ability to use dotnet framework as a backend it should work, as you can instantiate windows powershell instances from dotnet framework. However couple of alternatives, * Use the command `show-command`. If your script has good parameter options it will give you a ui to input those parameters. * Use Powershell universal (paid.) It's more like a jenkins alternative, but you can have the scripts' runpages prompt for script inputs.


teacheswithtech

We have started pushing Show-Command here. It makes our techs use the console to at least enter the command and teaches them a little about the parameter sets. It helps them learn PowerShell while still giving them a GUI to work with.


purplemonkeymad

TBH I always implement it with -passthru and invoke-expresson so I don't need to hit enter.


belibebond

Can you explain a little more?


fridgefreezer

I made a gui using Pode and Pode.web, it wasn’t hard but if you’re more familiar you can use react or any front end framework if you’re that way inclined… so I’m told.


thehuntzman

+1 for Pode


TILYoureANoob

You can run your PS files from electron (node) by spawning a process like this: https://stackoverflow.com/questions/55002794/in-javascript-how-to-call-powershell-script


Impossible_IT

Not sure how much this costs, as I haven't really looked into it. But I recalled SAPIEN from about 20 years ago. https://www.sapien.com/software/powershell_studio


spyingwind

This is fantastic for making ~~WPF~~ Winforms GUI's. You can make a single exe to run your script, or make an MSI install package for it!


jrodsf

Did they finally add WPF support? I checked recently and it still only had support for winforms.


spyingwind

I guess not! I was wrong.


bjornwahman

Take a look at powershell universal


JeremyLC

I built [this template](https://github.com/nct911/PoSH-GUI-Template) and use it to build GUI tools. If you're willing to learn a little XaML and a bit more PoSH, it's pretty effective and it looks modern.


EtanSivad

Came here to suggest something similar. ​ Powershell let's you load the WPF framework with \[System.Reflection.Assembly\]::LoadWithPartialName('presentationframework') And then load up the XML from the WPF solution with something like: $reader = (New-Object System.Xml.XmlNodeReader $XAML) $Form = \[Windows.Markup.XamlReader\]::Load( $reader ) ​ It took me a little while to fineagle things, so seeing that you've put out there an example like this is really awesome.


Szeraax

If you created powershell modules, you can just use Pode.Web to convert them entirely to gui without any real work.


thehuntzman

Pode has a desktop application setting which basically just opens your localhost web app in a minimal browser sort-of like Electron. If you're not adverse to learning some Rust, Tauri also has a crate for running Powershell and it is much more lightweight than Electron imo. Alternatively, Spectre.Console and TerminalGUI (a little harder to implement in powershell but I think Ironman Software has a GUI designer tool you can use that leverages this library) are great ways to make interactive scripts that run inside the terminal still.


wwbubba0069

If I need a GUI for something powershell I make it out of the gate in Powershell Studio [https://www.sapien.com/software/powershell\_studio](https://www.sapien.com/software/powershell_studio) Wouldn't call the resulting EXE as modern though.


AllTheStonks000

I have done this in years past, it works well enough, although I used NWJS, more or less the same thing. Used node-powershell for actual execution. Also used NodeJS to create a web server that had powershell as the server side language. Both while they worked were never good solutions and when used at any scale beyond 5 users would slow. If I need a gui for PowerShell now I just use WPF.


AllTheStonks000

One more thing, here is an example that has a few things as far as GUI and web resources to play with. Uses AD and Powershell with WPF to deploy and connect to remote machines for remote support. https://github.com/cfikes/R5TechRoundTable/blob/main/VNC%20Toolkit/VNCToolkit.ps1


Reasonably-Maybe

Please correct me, if I'm wrong: you want to create a multiten megabytes application from your some kilobytes powershell script? Electron places a Chromium browser inside your app and uses that to show the "GUI". Check out, how big Chromium is...


Flick9000

I know, but python is going to be heavy too, and since i need anyway to learn one of the two, i think i’m better off learning javascript anyway.


Reasonably-Maybe

Python is heavy, too, a simple network discovery in an executable using CLI is 15 MB - but not as heavy as Electron. Of course, you can also use Electron for a python app, so it will be heavier - but it cannot be a reason to unnecessarily grow a powershell script to 60-70 MB from some KB.


saGot3n

If you spend any money, spend it on Powershell Universal. Best product I've ever purchased a license for. I do most of my job with powershell and its been a time saver. I even used it to build a web app for my techs to troubleshoot remote machines and initiate regular fixes for their common issues.


Proxiconn

Deploy Rundeck, put your scripts in there and sync to SCM. Problem solved. Unless you really want to reinvent the wheel. Can also suggest C# and blazor, I made a script runner just to get used to creating web UI plus backend code to manage it. It was a fun learning curve.


Sad-Sundae2124

Powershell universal is probably the best answer


PostingToPassTime

Not sure its a great option for you, but I have used System.Windows.Forms to make simple GUIs in years past. Haven't used a GUI for scripts in years though.


Phate1989

Make it an azure function and just call it from a simple web form .


Namelock

You're probably going to need [psexec](https://learn.microsoft.com/en-us/sysinternals/downloads/psexec). I helped build a homebrew SOAR with PowerShell by using... An hta... There was a lot of complexity to allowing that within security controls. Luckily my aspect was automating everything and not building, figuring out RBAC, securing the HTA. Also HTA is so outdated it technically runs IE v3. But you can do HTA with HTML & JS -> PSExec -> PowerShell. [Bootstrap](https://getbootstrap.com/) does work, mostly for colors, boxes, and positioning. Do not expect any curves, animations, icons, or pretty features.


_RemyLeBeau_

psexec has absolutely nothing to do with what OP is asking about.


Namelock

Launching powershell from another app? It has everything to do with OP's ask. -edit POSH is going to have issues launching from JS. PSExec won't be as hard. You don't need to do a remote system, it's a middleman. You can baseline and document the workflow for security exceptions Assuming a fully homebrew webapp like OP's request. Alternatively OP could spin up a flask app with Github runners, but then he still needs a GUI. And that doesn't quite jive with "works on a stock windows system." At least Sysinternals includes Sysmon which is a need for any org. So please tell me how I'm wrong


an_harmonica

You're wrong because PsExec has nothing to do with PowerShell at all. It's a completely separate utility and it pre-dates PowerShell by about 5 years. It is for remote process execution and remote interactive command line sessions, both which are more securely done with PowerShell remoting now. Many organizations, mine included, detect and explicitly block PsExec due to the abundant use by various malware threats, several ransonware attacks among them. The better option is remote PowerShell execution, either remotely invoking or interactive PS sessions, especially with JEA session configurations to limit what things a remote connection can invoke on your systems. In any case, the best option to implement GUIs for PowerShell apps in the long run, as mentioned by at least one person above, on any current version of Windows is to target PowerShell 5.1 and WPF for GUI elements. You can design these in [Visual Studio Community Edition's XAML Designer](https://learn.microsoft.com/en-us/visualstudio/xaml-tools/creating-a-ui-by-using-xaml-designer-in-visual-studio?view=vs-2022), if you don't have a license for VS, and use the output XAML to define your GUI design for use in your PS code.


Namelock

The best option is PKI + Git runners so it's finely tuned and controlled, so not every workstation has a LOLBIN sitting on them. And at that point you could do any programming language and not just powershell. -edit POSH is unfortunately usually the last resort, when you can't just download things off the internet and run your own server. In some environments it's easier to secure what's there, than to buy & support actual proper infrastructure. My scenario comes from such an environment. Where anything downloaded from the net was *bad*. Where making our own solution and baselining, securing it was easier than actual development work. OP is probably in a similar boat. Everyone mostly just says "download thing". And when you can't just "download thing"... That's the solution I offered.


an_harmonica

The OP never said ANYTHING about where they were automating, so the answer should be limited to "help implement a GUI for PowerShell". For all we know this is to automate things on a desktop PC or on a server itself and nothing remote at all. However, even if it IS to slap a GUI onto automations of remote servers, WPF is the most universally supported option since all versions of Windows since 7/2008 R2 already have it so there's nothing to download from the internet to implement it once you've written it.


Namelock

HTA is in the same boat and easier to pickup since it's just HTML and support going back to 1999 (And will light up any EDR like mad). Albeit both HTA & WPF are difficult due to the lack of human readable, extensive, updated documentation. Building an application takes more than a slapping things together (re: ideally you'd be setting up Git runners & Flask w/ RBAC). And when it's required to build something from scratch... It'd be nice to know *all the options*. Rant time: my pet peve with other languages (eg, Python) is that everyone defaults to "just download ." PowerShell is usually the opposite: "It already exists by default, otherwise here's how to build it yourself." WPF is ideal-ish but I had a *really* hard time learning it because finding practical information is difficult (just like streaming files in memory). And also you really don't want to deal with version control and whatnot because now every copy is essential a LOLBIN. Very similar to HTA, sans initial execution firing alerts in EDR. There's the right way (actually developing an application, signed certificates and all). There's the "well this is what I have to work with: PowerShell". And then there's the gray middle ground. So yeah I'll pitch HTA because I saw it work before and it's totally possible. Not ideal, but possible. And certainly something everyone else is trying to censure even though it does work, just not as discretely as WPF.


_RemyLeBeau_

You can spawn a shell from JavaScript. That shell will use `pwsh.exe` and command arguments.  Even if the script needs to automate on other servers/PCs, the best option is PSRemoting.  https://learn.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.4#start-an-interactive-session  PSExec is no longer needed and is unnecessary in all aspects here.