Powershell GUI

HI All,

I need to produce GUI's for our helpdesk, what is the best way of doing this. The GUI will grab information, example -  mailbox sizes greater than 5 gb and then the GUI will have a button to migrate the mailbox.  

thank you in advance,
Kay
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:
This is a complex topic I'm afraid. To be honest, every time I've done this I've ended up shifting to C#. PowerShell is not the best language for creating user interfaces.

You might consider using ShowUI, it significantly simplifies the job of building the GUI:

http://www.show-ui.com/

If you do, you will also have to distribute the ShowUI to helpdesk staff.
0
Rajul RajInformation Security OfficerCommented:
1
Shaun VermaakTechnical Specialist/DeveloperCommented:
Fairly straight forward. You can also use Visual Studio to design GUI and just use it in Powershell with a couple of tweaks

function Load-Form {
    $Form.Controls.Add($Button1)
    $Form.Controls.Add($Label)
    $Form.Add_Shown({$Form.Activate()})
	[void]$Form.ShowDialog()
}

Function ButtonWasClicked{

}

# Form
$Form = New-Object System.Windows.Forms.Form    
$Form.Size = New-Object System.Drawing.Size(900,450)  
$Form.MinimumSize = New-Object System.Drawing.Size(900,450)
$Form.MaximumSize = New-Object System.Drawing.Size(900,450)
$Form.SizeGripStyle = "Hide"
$Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + "\powershell.exe")
$Form.Text = "Title"
$Form.ControlBox = $true
$Form.TopMost = $true

#Draw buttons 
$Button1 = new-object System.Windows.Forms.Button
$Button1.Location = new-object System.Drawing.Size(60,370)
$Button1.Size = new-object System.Drawing.Size(90,25)
$Button1.Text = "Click here..."
$Button1.Add_Click({ButtonWasClicked})
$Button1.Visible = $True
$Button1.Enabled = $False
$Label = New-Object System.Windows.Forms.Label
$Label.Text = ""
$Label.AutoSize = $True
$Label.Location = new-object System.Drawing.Size(160,375)

# Load form
Load-Form

Open in new window

1
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

aikimarkCommented:
Sapien makes a good GUI IDE for Powershell scripts.
0
Chris DentPowerShell DeveloperCommented:
I thought Sapien discontinued primal forms? Certainly not kicking around much any more.

I think I should clarify this statement:

> This is a complex topic I'm afraid.

Designing the initial front end with a few buttons is easy. Wiring up the back end, so you can execute things, get information back, properly handle errors and exceptions, present information, act on it, all of this takes a lot of time. This is especially true when you're dealing with longer running tasks that must trigger a change in a UI-thread when they're done (without completely locking up the GUI for the duration).

I will hold fast to my opinion that PowerShell is not a good language for developing GUIs. You can... but outside of very, very simple utilities it becomes quite a drag.

ShowUI goes a long way to mitigating this lack by providing a background jobs interface, my last project couldn't use that because it auto-builds itself on first import and every import was a first in the environment in question.
0
aikimarkCommented:
https://www.sapien.com/software/powershell_studio

still lists GUI Designer as a prominent feature.
1
Shaun VermaakTechnical Specialist/DeveloperCommented:
I won't pay $389 for something I can do in Community VS/Notepad++ though
0
Bill PrewCommented:
A decent example of a Powershell UI via forms in this solution to a prior problem, hope it's helpful.

https://www.experts-exchange.com/questions/28982303/Help-to-convert-powershell-script-into-a-gui.html#a41884032

~bp
2
Chris DentPowerShell DeveloperCommented:
PrimalForms was free way back when. It was all Forms though. Being able to "draw" most of the GUI in a XAML document is quite an advantage (over dynamically generating every single control) with WPF.

As Shaun says, VS community is free and it has a forms designer. It could be used to build up the main GUI part.

Beyond that I think you should break this problem down. If you must have a GUI, what should the minimum viable product include?

If you take this part as an example:

> The GUI will grab information, example -  mailbox sizes greater than 5 gb

This means you need to execute some PowerShell, and you need to display the results.

How should that be displayed? In a list?

> The GUI will have a button to migrate the mailbox

This control will have to be dynamically generated.

Where will the button appear? How will it be generated? What, exactly, will it do?
0
Kelly GarciaSenior Systems AdministratorAuthor Commented:
I am using wpf to build the gui, what are your thoughts? is there a better way??
0
Chris DentPowerShell DeveloperCommented:
WPF is about as good as it gets in my opinion.

I do recommend you define as much as you can in XAML, load it and wire up everything else in PowerShell, but at least it saves you writing all of the controls in code.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.