I put together this short tutorial using ShowUI (download ShowUI HERE). ShowUI is a PowerShell module to help build WPF user interfaces in script. You can use ShowUI to write simple WPF gadgets, quick front ends for your scripts, components, and full applications.
Basic Building Blocks
In the video I demo the basic building blocks you’ll reuse over and over. New-Window, New-StackPanel, New-Label, New-Button and more.
Take a look and let me know what questions you’d liked answered. I’ll include them in the next set of video tutorials.



{ 4 trackbacks }
{ 5 comments… read them below or add one }
Clever musical choice.
If you’re taking requests I’d like to see the following simple workflow type things:
- Picklist from an array. I’m thinking something like what you see from out-gridview except I can multi-select (and/or apply a constraint and select-all) and then push all the selected objects back into a variable. A visual ‘where-object’ in a way. Bonus would be to show only relevant info visually yet have the entire underlying object used for the display in the final selection.
- Status indicator. I run a lot of ‘fan out’ type operations with Invoke-Expression lately across a web farm. Normally I either run it as a background job and don’t see anything until it’s all done, or I run it serially without -AsJob and just watch things roll by in the console. I want to throw up a uniform grid type control with an icon/label for every server and periodically update them as sub-operations complete.
I’m not necessarily looking for complete solutions, just some general pointers. Thanks for the great Powershell blogging!
Thanks Paul. Those are great requests. Check out Edit-StringList . It is somewhat along the lines of what you are asking. I try an work up what you suggest.
Please leave more requests if you have them and feel free to do the same at the ShowUI CodePlex Discussions List
@Paul Chavez: For the status indicator you should use the built-in Write-Progress indicator. As long as you separate the indicators by using unique IDs receive-Job will happily report on multiple jobs at the same time:
$jobs = (
1..5 | %{
start-job {
param($job); 1..100 | %{
sleep -milli 100; write-progress "reporting on $job" "waiting..." -id $job -percent $_
}
} -arg $_
}
)
$jobs|?{$_.State -ne 'Completed'}
do { receive-job $jobs; sleep -milli 100 } while( $jobs|?{$_.State -ne 'Completed'} )
@Uffe, good solution. I believe Paul wants the indicators to show up in a WPF GUI using ShowUI.
Thanks, Uffe. That would work for my current workflow since I’m running discrete commands with Invoke-Command and -AsJob, but I would like to move to using sessions in the future. The scenario is a rolling update of a web farm where some of the operations are done in parallel and some are done in a ‘rolling’ fashion to keep from taking the entire cluster down at once. So the end result would be more of a reporting of the state of a particular node, rather than a generic progress bar.
I am a bit ashamed to say I didn’t look at the examples included with ShowUI before posting my initial question, and there already is a session manager in there which gives me a nice head start on the issue. I would have seen Edit-StringList before asking, for instance. I guess I just like my info spoon fed to me in blogs.