My First experience with GUI in PowerShell, If you know how to manipulate the form you can make very powerful GUI apps for Help desk and for the team members. Lets see it how it works.
The version of PowerShell is 3.0.Add a .NET Framework type to a PowerShell session. If a .NET Framework class is added to your PowerShell session with Add-Type, those objects may then be instantiated (with New-Object ), just like any .NET Framework object.
#=====================Begin of the Script===========
Add-Type -AssemblyName System.Windows.Forms
#Create function to add two numbers, You can create your own function.
function add ($objTextBox2,$objTextBox1)
{
$a1=[int]$objTextBox1
$a2=[int]$objTextBox2
$Get=$a1+$a2
$outputBox.text = "$Get"
}
#System.Windows.Forms.Form will create a blank form, Lets create a object.
$Form = New-Object system.Windows.Forms.Form
$form.Size = New-Object Drawing.Size @(1000,10000)
############## Create Input BOX1
$objTextBox1 = New-Object System.Windows.Forms.TextBox
$objTextBox1.Location = New-Object System.Drawing.Size(10,40)
$objTextBox1.Size = New-Object System.Drawing.Size(260,20)
$Form.Controls.Add($objTextBox1)
########################### End of Input Box1
$objTextBox1.Text
############# Create Input BOX1
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Location = New-Object System.Drawing.Size(10,4)
$objTextBox2.Size = New-Object System.Drawing.Size(260,2)
$Form.Controls.Add($objTextBox2)
########################### End of Input Box2
$objTextBox2.Text
############# Create OutBOX
$outputBox = New-Object System.Windows.Forms.RichTextBox
$outputBox.Location = New-Object System.Drawing.Size(10,150)
$outputBox.Size = New-Object System.Drawing.Size(565,200)
$outputBox.MultiLine = $True
$outputBox.ScrollBars = "Vertical"
$Form.Controls.Add($outputBox)
########################### End of Outbox
#################Create the ADD Button
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(400,30)
$Button.Size = New-Object System.Drawing.Size(110,80)
$Button.Text = "ADD"
$Button.Add_Click({add $objTextBox1.Text $objTextBox2.Text})
$Form.Controls.Add($Button)
#####################End of Button
$drc = $form.ShowDialog()