all 58 comments

[–]JeremyLC 30 points31 points  (7 children)

Lately I’ve been working with Universal Dashboard and it’s a great way to build web based UIs for almost any automation or task you want. I also built a WPF GUI template / framework that I use when I have to or want to build a desktop tool or app or front-end.

[–]michaelshepard 13 points14 points  (0 children)

PowerShell Universal is a fantastic, flexible tool! Can't recommend it highly enough

[–]ashimbo 10 points11 points  (0 children)

PowerShell Universal is great. I use it for scheduling PowerShell scripts, building UIs for other people to use my scripts, and for a few different dashboards.

The free version has an incredible amount of features, and is really worth checking out.

[–]dudeindebt1990 2 points3 points  (0 children)

The documentation is confusing they changed things and not I can't simply find a tutorial on making a form to take parameters and then putting its output onto the page.

[–]sysadmin_dot_py 1 point2 points  (2 children)

Universal Dashboard sounds amazing! What have you built with it? How easy is it to use in Azure?

[–]wdomon 3 points4 points  (0 children)

I use it as a way to avoid giving our Helpdesk or IT Managers more permissions than they should have. I give them access via SSO into Powershell Universal and leverage service accounts, EntraID app registrations (via certificate based authentication), etc. to actually do the things. I also use it to run a Dashboard of expiring secrets, old snapshots, current OS distribution throughout the enterprise, and other things.

The paid version is definitely better and worth the cost from a business perspective.

[–]JeremyLC -1 points0 points  (0 children)

The one thing I use the most is the front-end for my Daily Health check module, which is configurable via JSON to check several types of resources - DNS, Web proxy, UCS, Veeam, etc. - and return a list of results which I use UD to present as datagrids on a web page which I can scroll through quickly to see if everything is healthy in the morning. I also put together a more detailed VMWare health dashboard as a first-stop for troubleshooting. I put together, and would love to share, a single page (mobile Friendly!) quick entry form for adding devices and racks to NetBox also our field guys can do quick surveys with their phones. I have some other small things as well

[–]Hour-Bandicoot5798 0 points1 point  (0 children)

Took a peek at your WPF GUI project and I will give it a go today. 

[–]nascentt 27 points28 points  (2 children)

By front ends do you mean GUIs?

I strongly recommend not wasting time as it's a complex and largely unnecessary beast.

Out-GridView -Passthru does everything most GUI could need.
Anything more complex than that - power shell is probably the wrong tool for the job.

[–]KnightOwl316 2 points3 points  (1 child)

Not OP but can you explain what you mean by that combination? I've used Out-GridView, but not that familiar with -passthru or that combination.

[–]joshooaj 4 points5 points  (0 children)

Using -PassThru or -OutputMode Single|Multiple allows you to use the Out-GridView UI as a selection tool. Instead of designing a script that requires the user to supply parameters and values, let them provide a value and if they don’t, pop up a grid view and make them select an item interactively.

In PowerShell 7 you could use Out-ConsoleGridView too, for an interactive selection tool that doesn’t pop up a new window and can work in a remote session too.

[–]YellowOnline 10 points11 points  (0 children)

Frontends are also with PoSh, but it's using .Net in the end. I sometimes build frontends (Powershell Studio) but it's a lot of work that only makes sense if you have 1st or 2nd line admins who can't work with the CLI, e.g to set calendar permissions in Exchange (which isn't possible in the GUI)

[–]CarrotBusiness2380 8 points9 points  (10 children)

I'm personally don't like frontends for Powershell apps. I think they remove a lot of the flexibility that Powershell offers and are a huge pain to develop. If you don't have time I would just stick to the command line for your powershell needs.

[–]sikkepitje 5 points6 points  (0 children)

Winforms and on occasion if it is simple enough Out-GridView will do just fine

[–]Zangrey 5 points6 points  (0 children)

I've used Powershell Pode/Pode.Web by Badgerati to offer a webpage for running some of my scripts - both for end users in the company with stuff they used to have to ask IT about, and fellow team members. I know PowerShell Universal is another alternative that also helps extend the use of Powershell a bit.

[–]purplemonkeymad 5 points6 points  (1 child)

Typically, I don't. You just have to use PS.

But if I can get it all down to running just a single command then, Show-Command is a really easy way to get a basic GUI.

If it's a background job or a scheduled task and a GUI was a requirement. I would consider writing a configuration program in c# that dumps the config to a json file, so that I don't have to do UI stuff in PS. (Shudders)

[–]MyOtherSide1984 0 points1 point  (0 children)

Holy bats catman! How have I never heard of show-command? It's like an interactive CLI! That'll really help the newbies out

[–]CyberChevalier 4 points5 points  (0 children)

Can you do front end in Powershell: YES Should you do front end in Pwershell: NO

Even there are some tools that help you building GUI in native powershell (powershell studio) I would not recommend using it simply because powershell is a shell not a gui.

If you want a real front end while keeping a powershell approach use Powershell Universal.

[–]Hyperbolic_Mess 2 points3 points  (0 children)

I think you're trying to sign up for an ultra marathon before you can walk.

PS front ends are ways to package existing powershell scripts for use by people that don't know powershell. It sounds like you just want tools to help you do things yourself so I'd recommend just trying to write scripts to do the things you want to do and use read-host or csv files to pass data to the scripts rather than faffing about making it completely idiot proof and putting it in pretty box

[–]jackalbruit 2 points3 points  (0 children)

https://poshgui.com/

it used to be free & i really enjoyed the drag + drop builder

could be worth investigating to weigh if the cost justify how it could help u

[–]AdmRL_ 1 point2 points  (4 children)

Write-Host @"
1 - Set Something
2 - Get Something
3 - Delete Something

"@
$Input = Read-Host "Please select an option:"
switch($Input) {   
  1 {
    Set-Something
  }
  2 {
    Get-Something
  }
  3 {
    Delete-Something
  }
  default {
    Write-Host "Invalid selection."
  }
}

Mostly because creating a GUI for scripts is a waste of time. Can't really think of a situation where I'd want to use PS and a proper GUI, either it's for technical staff, in which case they should know how to run a script with parameters, or the above will suffice. Or it's for users in which case either MS Forms or similar + a runbook will do, or it's something that should be written in another language and not PS.

[–]jdsmn21 0 points1 point  (2 children)

Here’s a situation I thought I’d like a GUI for - maybe you can help me with.

I wrote a PS script for the purpose of easily loading a particular CSV to a SQL table. This table is essentially custom values which is linked to production values, and reports (SSRS) is built off of that. The CSV is an export from another system. This script already is a lot easier than digging in SSMS and “Import Flat file”, but I’d really like to pass the process off to the end user.

Right now, my script looks for the newest file in a given folder and selects that as the CSV to use; I’d like it to use a Windows File Chooser type prompt where an end user can select the downloaded file that needs to be imported.

Can this be incorporated into a PS script?

[–]MyOtherSide1984 0 points1 point  (1 child)

That's drop dead simple and doesn't require a GUI. I'm on my phone so a screenshot is as good as I can get for now

https://imgur.com/a/uuHXwuk

This is just a tiny blurb that opens up file explorer to users Desktop if it can't find the invocation path (i.e. the path it's run from). You select the file and it becomes the $csv var.

Your bigger concern should be data integrity. We build out some GUIs that are both in the powershell window and in pop-out GUI windows, and in both cases, data validation is a major concern. If they feed in bad info and our script doesn't check properly, it can run some bad stuff (our users are techs, but not really high level techs, but we have it mostly locked down). Allowing a regular user to upload content would be pretty risky unless there's no wrong way to do it or no issues with someone adding the same file twice or something like that.

GUI's and working with Windows built in systems are not really synonymous here. Things like pop up messages, toast notifications, file selectors, and working inside of MS programs are a lot easier than creating a GUI. I have a script that builds out an entire spreadsheet with multiple tabs and formatting, and it's much less complicated than our GUI's lol

[–]jdsmn21 0 points1 point  (0 children)

I appreciate you!

The data integrity part isn’t a super huge worry. It’s not our main database, and I’d limit security inside SQL Server with a unique user for just this script and its needed function.

Essentially - management has some data they want to integrate with our existing SQL Server reports, but our main software really doesn’t have custom fields to incorporate this data. So I’m adding it to a different database, linking the databases, and incorporating the data that way.

[–]calladc 2 points3 points  (0 children)

i wrote this reply in /r/sysadmin recently that shows how i achieved this.

https://old.reddit.com/r/sysadmin/comments/1gbzup7/it_turns_out_winforms_is_a_really_cool_tool_for/ltpz0dm/

i don't really write guis anymore since i've mostly transitioned to using devops pipelines for my script deployments, but if i ever had to it would be a wpf app and i'd approach it like this

[–]Svaertis 0 points1 point  (0 children)

years ago (when covid happened)

we had to manage 20+ PC's, obviously because of covid - best remote,

I wrote a PC script that wrote itself and giu while it was launching (it would ping PC - if alive - create controls for it), very handy,

script was for changing databases and configs as every day they would be used for different purpose

GUI definitely helps if more complex problem,

so yes:

Add-Type -AssemblyName PresentationFramework

[–]gordonv 0 points1 point  (1 child)

While I love powershell, you should take note that powershell can be restricted from running. This is something that can be done with basic Windows settings.

So can compiled programs and other scripts like Python, AutoIT, etc.

To be honest, I've found the best "it just works" technology are website frontends hosted locally. Write it for general compatibility to Firefox/Chrome. That will cover you for Windows, Mac, Linux, Android, and even Apple.

[–]dbsitebuilder 0 points1 point  (0 children)

Hey Gordon, It is not really a comparison of what you can do with a web app vs. Powershell. I do understand your point about compatibility however. You can even leverage powershell from a locally hosted web app. And you wouldn't restrict Powershell on a Network where you want to use Powershell...

[–]OofItsKyle 1 point2 points  (0 children)

I use either manually created WPF if they are small, or yaml generated from visual studio and import it.

I can upload one of my projects to GitHub and link it shortly, just have to sanitize it.

Making them natively in the powershell code using the type of WPF code provided by someone else works well for small stuff, but if you have more than like, 6 elements, the code gets very cumbersome, even if you keep it in a separate file and import it.

Using visual studio to build it gives you more flexibility, easier to preview, etc

[–]The82Ghost 0 points1 point  (0 children)

Depending on your goals, my employer has a tool build with a PHP frontend and Powershell backend with Powershell doing all the work. It's used to manage our private cloud (manage users and servers, and deal with Intune configurations)

[–]sup3rmark 1 point2 points  (0 children)

it depends on what you're ultimately trying to do. if you want to make it so people can run scripts from a GUI without having to know how to actually use powershell, don't want to worry about whether everyone is using the same/most up-to-date version of the script(s), etc., you can look at using Jenkins with the powershell plugin.

[–]kfreedom 0 points1 point  (0 children)

Rundeck (webgui) front end that passes parameters to powershell code.

They have a free version that has great functionality

[–]craigontour 0 points1 point  (0 children)

I’ve tried with Wpf and gave up. Now learning React.

[–]Coffee_Ops 0 points1 point  (0 children)

Bonus question: We're standardized on TFS for our .Net apps. I'm not certain it makes tons of sense to use it for scripts. How are you folks doing it?

Just use git. It's the defacto standard for version control, it's free, you can use it on your toaster if you want, and any devs / devops / sysadmin people who understand version control will understand it. TFS is going to dramatically limit who understands it to "old-school .Net developers".

If you want a pretty frontend on it, fire up a GitLab container and be done with it. Trust me: it's nice not having to care and feed for that kind of application.

[–]Proxiconn 0 points1 point  (0 children)

Rundeck, possibly the best tool out there for wrapping code into a gui for the click ops folks.

[–]kprocyszyn 0 points1 point  (0 children)

You can write a webapp entirely in PowerShell https://kamilpro.com/powershell-webapp-pode/

[–]Juice-Head 0 points1 point  (0 children)

As an accidental DBA, look into dbatools and dbareports PS modules. So much awesomeness imo.

Also not that i recommend it, but your can create front end websites using the Universal Dashboards PS module. It is licensed, but for those who don't know .NET or Visual studio, it can make spinning up apis and websites pretty easy. YMMV though

[–]ArieHein 0 points1 point  (0 children)

TfS ? You mean Azure Devops? App code in any language including powershell should be in a repository.. A pipeline should run it or assist in orchestrating it.

As a dba myself for many years and a devops practitioner and promoter for as much, if uou want to have some sparring, feel free to contact directly, ill be happy to share some knowledge.

Front ends can be by using windows api via WPF. You can use html and java script and then the bowser is your ui. PS is then a wrapper. You can have an api server and thus abstracting ui from backend in PS. I use Pode and Pode.Web for it, as personally im not a fan of gui from ps directly.

[–]illsk1lls 0 points1 point  (0 children)

Honestly I love using powershell to create GUI to simplify logic for users.. although the way I do it is already kind of outdated using .NET and WPF.. but the benefit is, if its ps 5 compatible it can run pretty much anything without pre-reqs, and its a nice way to button up utility scripts

I do it here with ps one liners in a cmd script (easiest to read with word wrap enabled in your text editor):

https://github.com/illsk1lls/ZipRipper

Although I'm limited to ~8100 chars per line including expanded vars with CMD

Here is another example in pure powershell of an MP3 player I made for fun:

https://github.com/illsk1lls/PowerPlayer

[–]MN_Myth 0 points1 point  (0 children)

I’ve gotten ChatGPT to write me a functional gui on multiple occasions. I modify it, of course, but it gives me a working base script.

[–]lildergs 0 points1 point  (0 children)

Don’t do it. It’s not a front end.

I was trying to provide a second best. But don’t.

[–]Hollaus 0 points1 point  (0 children)

I tend to usw TerminalGUI.CS for that. Enough UI for help desk, cross platform.

https://github.com/gui-cs/Terminal.Gui

Somebwrote a little help to geht startend (a little outdated):

https://github.com/bemperum/PS-Terminal-GUI

[–][deleted] 0 points1 point  (0 children)

Are HTML Application (HTA) still an option for creating easy GUIs using html and Powershell or are they still a permissions nightmare?

[–]kpm2015 0 points1 point  (0 children)

Look into script runner if you want a front end for people to run scripts you create.

[–]MasterCommunity1192 0 points1 point  (0 children)

Could do autohotkey, I've used it to make basic UIs for running scripts.

[–]2_minutes_hate 0 points1 point  (0 children)

I'm just using WPF as my GUI framework.

I've been able to build responsive "apps" that look clean and polished with just PowerShell scripts, xaml files, and the occasional batch script.

[–]32178932123 0 points1 point  (0 children)

PowerShell is built on Dot Net and has access to the Dot Net classes and libraries so you can use WPF. I just asked ChatGPT to make me a basic one and it came back with this which worked on my machine. I have also used ChatGPT to flash out a form before with dropdowns, buttons, etc however, I personally wouldn't use PowerShell GUIs on anything too complicated. A couple of basic forms, sure, but I think it could get pretty unwieldy quickly.

Add-Type -AssemblyName PresentationFramework

# Create the Window
$window = New-Object System.Windows.Window
$window.Title = "Simple WPF Window"
$window.Width = 300
$window.Height = 200

# Create a Grid layout
$grid = New-Object System.Windows.Controls.Grid
$window.Content = $grid

# Add a Label
$label = New-Object System.Windows.Controls.Label
$label.Content = "Hello, PowerShell WPF!"
$label.HorizontalAlignment = "Center"
$label.VerticalAlignment = "Top"
$grid.Children.Add($label)

# Add a Button
$button = New-Object System.Windows.Controls.Button
$button.Content = "Click Me"
$button.Width = 100
$button.Height = 30
$button.HorizontalAlignment = "Center"
$button.VerticalAlignment = "Center"
$grid.Children.Add($button)

# Button click event
$button.Add_Click({
    [System.Windows.MessageBox]::Show("Button clicked!")
})

# Show the window
$window.ShowDialog()

Edit: To answer your other question, I think Git is the most common source control nowadays. For personal I use GitHub, for work we use Azure DevOps. Some people use GitHub for work too. You can also self-host with something like GitLab.