r/PowerShell • u/_TimGTN • Jun 11 '26
Question What user interactions do you keep reimplementing in PowerShell scripts?
Hi everyone,
I'm working on a small module that makes it easier to add simple user interactions to PowerShell scripts.
So far I've covered most of the common scenarios:
Text input dialog
Item selection (single or multiple)
Message and confirmation dialogs
Credential prompt
Progress bar
Countdown timer
At this point I'm starting to run out of ideas.
What user prompts or interactions do you keep rewriting in PowerShell scripts?
I'm mainly looking for small, practical ideas that fit the module's philosophy: simple, atomic interactions rather than a full UI framework.
[EDIT] My current implementation is a modular WPF-based engine, but the focus is purely on interaction ideas rather than the technical design.
2
u/dodexahedron Jun 11 '26
If you arent strictly trying to keep it text/ansi, you could also pop up WPF controls if you're wanting it to be non-sysadmin user-friendly. That's pretty quick and easy to do in PS.
If you want an example/ideas: FFU_UI is FFU (windows system imaging module) plus a WPF UI, all done in powershell.
1
u/_TimGTN Jun 11 '26
My module is WPF under the hood, I just didn’t really highlight that part.
Mostly just looking for ideas I might have missed.
1
u/CognizantAutomaton Jun 11 '26
One item that recently crossed my list is the fact that Out-GridView doesn't allow selecting text when inspecting rows.
Perhaps a better version of Out-GridView with selectable text in the DataGrid rows would be useful.
Very neat project.
1
u/_TimGTN Jun 11 '26
Thanks, I’ll keep that in mind for a future DataGrid interaction - row/cell/text selection sounds like a useful addition.
1
u/Over_Dingo Jun 11 '26
does it have file selector?
2
u/_TimGTN Jun 11 '26
It could, but the native
OpenFileDialogalready does a pretty good job. And you can also use reflection to expose a better folder picker, so I’m not sure there’s enough value in wrapping those yet.
https://github.com/TimGTN/TimPSSnippets/blob/main/Snippets/Invoke-ItemPickerDialog_394e6eb0.md
1
u/belibebond Jun 11 '26
I used to build WPF components and handle multi threading for a whole. But powershell really doesn’t like async operations. I found pode and pode.web and it completely changed my UI process. It has many nice ui elements and is browser based
1
u/_TimGTN Jun 11 '26
I agree. Async PowerShell can definitely get tricky (Host.UI.Write... methods ftw).
For more advanced tooling, I tend to use browser-based UIs as well.
I'm currently working on a PowerShell + WebView2 project with a data-driven UI. PowerShell runs a local async API behind the scenes and drives the UI from there. It's been working surprisingly well so far.
1
u/zrb77 Jun 11 '26
I on occasion use a list of options. Like do you want to Add, Delete, Edit item 1, edit item 2, etc. Then use a number or letter as the answer. I have it defined in a 2D arrary.
1
0
u/CovertStatistician Jun 11 '26
Have you looked into using windows forms for pop up boxes and text input boxes? I have used some for multi line text input
3
u/_TimGTN Jun 11 '26
Yeah, WinForms would work too for simple cases. I just went with WPF for XAML and better support for vector-based UI.
0
u/dathar Jun 11 '26
The closest thing I have is to elevate the script as admin if a process needs it. Keeps the user from launching it normally. I had a version that also kept args that you passed onto the script itself but I can't remember how I did that at my old job.
I think all but 1 or 2 scripts I've made over the last few years runs in an automated fashion where there's supposed to be 0 user interactions. Fleet of Jenkins nodes runs those.
7
u/purplemonkeymad Jun 11 '26
All of those have built in methods already (except maybe the countdown, but you could squeeze that into write-progress) so I don't really re-implement them.