$Location = Split-Path $MyInvocation.MyCommand.Path -Parent Function Start-Form { $Global:Collection_Name = "" #$Global:Select_Tool = "" $Global:Output_Type = "" $Temp = "" [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $Form = New-Object System.Windows.Forms.Form $Form.Size = New-Object System.Drawing.Size(600,400) ############################################## #$Form_Load={ $outputBox.text = "Welcome" } ############################################## Start functions <# function pingInfo { if ($RadioButton1.Checked -eq $true) {$nrOfPings=1} if ($RadioButton2.Checked -eq $true) {$nrOfPings=2} if ($RadioButton3.Checked -eq $true) {$nrOfPings=3} $computer=$DropDownBox.SelectedItem.ToString() #populate the var with the value you selected $pingResult=ping $wks -n $nrOfPings | fl | out-string; $outputBox.text=$pingResult } #end pingInfo #> ############################################## end functions ############################################## Function temp { $outputBox.text = $textBox1.text | Out-String $Global:Collection_Name = $textBox1.Text #$Global:Select_Tool = $RadioButton1.Checked $Global:Select_Tool = $DropDownBox.text #$Global:Output_Type = #if ($RadioButton2.Checked -eq $true) {Get-Service | Out-GridView} If($DropDownBox.text = "Tool1"){gcc} $textBox1.clear() $DropDownBox.text = "----Select Tool----" } ############################################## Function Update-Dropdown1 { # $Collections += $textBox1.text $Collections = @("Tool1","Tool2","Tool3","Tool4","Tool5","Tool6","Tool7") $Collections | % { $DropDownBox.Items.Add($_) } } ############################################## Function gcc { $outputBox.text = Get-Service | Out-String } ############################################## Function Clear-Variables { $Global:Collection_Name = "" $Global:Select_Tool = "" $Global:Output_Type = "" } ############################################## Start group boxes $groupBox = New-Object System.Windows.Forms.GroupBox $groupBox.Location = New-Object System.Drawing.Size(270,20) $groupBox.size = New-Object System.Drawing.Size(150,110) $groupBox.text = "Select Output:" $Form.Controls.Add($groupBox) ############################################## end group boxes ############################################## Start radio buttons $RadioButton1 = New-Object System.Windows.Forms.RadioButton $RadioButton1.Location = new-object System.Drawing.Point(15,15) $RadioButton1.size = New-Object System.Drawing.Size(130,20) $RadioButton1.Checked = $true $RadioButton1.Text = "Powershell Window" $groupBox.Controls.Add($RadioButton1) $RadioButton2 = New-Object System.Windows.Forms.RadioButton $RadioButton2.Location = new-object System.Drawing.Point(15,35) $RadioButton2.size = New-Object System.Drawing.Size(80,20) $RadioButton2.Text = "Gridview" $groupBox.Controls.Add($RadioButton2) $RadioButton3 = New-Object System.Windows.Forms.RadioButton $RadioButton3.Location = new-object System.Drawing.Point(15,55) $RadioButton3.size = New-Object System.Drawing.Size(80,20) $RadioButton3.Text = "Export csv" $groupBox.Controls.Add($RadioButton3) ############################################## end radio buttons ########### Text Box ########### ############Define text box1 for input $textBox1 = New-Object “System.Windows.Forms.TextBox”; $textBox1.Left = 20; $textBox1.Top = 30; $textBox1.width = 200; $Form.Controls.Add($textBox1) ############################################## Start drop down boxes $DropDownBox = New-Object System.Windows.Forms.ComboBox $DropDownBox.Location = New-Object System.Drawing.Size(20,80) $DropDownBox.Size = New-Object System.Drawing.Size(180,20) $DropDownBox.DropDownHeight = 200 $DropDownBox.text = "----Select Tool----" $Form.Controls.Add($DropDownBox) ############################################## end drop down boxes ############################################## Start text fields $outputBox = New-Object System.Windows.Forms.TextBox $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 text fields ############################################## Start buttons $Button = New-Object System.Windows.Forms.Button $Button.Location = New-Object System.Drawing.Size(450,30) $Button.Size = New-Object System.Drawing.Size(110,80) $Button.Text = "Go" $Button.Add_Click({temp}) $Form.Controls.Add($Button) ############################################## end buttons Update-Dropdown1 $Form.Add_Shown({$Form.Activate()}) [void] $Form.ShowDialog() }