![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Pop-up to enter variables to pass to script Hi, I'd like to know how I create a pop-up, using .net, to populate it with variables that would be passed to my powershell script... thanks, |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Pop-up to enter variables to pass to script Here's a snippet from Jeffrey Snover ITForum presentation. Save it as get-GuiInput.ps1 and execute it: #Requires -Version 1 param ( $pstring = "Name?", [regex]$validationString = ".*" ) [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms") ############################### # Create the form $form = New-Object System.Windows.Forms.Form $form.add_shown({$form.Activate()}) $form.Text = "PowerShell GUI Input" $form.height = 110 ############################### # Create the label $label = New-Object System.Windows.Forms.Label $label.Text = $pstring $label.dock = "top" ############################### # Create the textbox for input $textbox = new-object system.windows.forms.textbox $textbox.dock = "top" $textbox.add_KeyUp({ if ( $textbox.text -Notmatch $validationString ) { $textbox.BackColor = "RED" }else { $textbox.BackColor = "white" } }) ############################### # Create the OK button and when the OK button is clicked hide the form $OK = new-object system.windows.forms.button $OK.Text = "OK" $OK.dock = "bottom" $OK.Add_Click({ $form.hide() }) ############################### # add the controls to the form $form.Controls.AddRange(@($textbox,$label,$OK)) ############################### # show the form $results = $form.showdialog() # show the results $textbox.Text $form.dispose() ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hi, > > I'd like to know how I create a pop-up, using .net, to populate it > with variables that would be passed to my powershell script... > > thanks, > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Pop-up to enter variables to pass to script Thanks Shay, that worked well. "Shay Levi" wrote: Quote: > Here's a snippet from Jeffrey Snover ITForum presentation. Save it as get-GuiInput.ps1 > and execute it: > > > #Requires -Version 1 > param ( $pstring = "Name?", [regex]$validationString = ".*" ) > [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms") > > > ############################### > # Create the form > $form = New-Object System.Windows.Forms.Form > $form.add_shown({$form.Activate()}) > $form.Text = "PowerShell GUI Input" > $form.height = 110 > > > ############################### > # Create the label > $label = New-Object System.Windows.Forms.Label > $label.Text = $pstring > $label.dock = "top" > > > ############################### > # Create the textbox for input > $textbox = new-object system.windows.forms.textbox > $textbox.dock = "top" > $textbox.add_KeyUp({ > if ( $textbox.text -Notmatch $validationString ) > { $textbox.BackColor = "RED" > }else > { $textbox.BackColor = "white" > } > }) > > > ############################### > # Create the OK button and when the OK button is clicked hide the form > $OK = new-object system.windows.forms.button > $OK.Text = "OK" > $OK.dock = "bottom" > $OK.Add_Click({ > $form.hide() > }) > > ############################### > # add the controls to the form > $form.Controls.AddRange(@($textbox,$label,$OK)) > > > ############################### > # show the form > $results = $form.showdialog() > # show the results > $textbox.Text > $form.dispose() > > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > Quote: > > Hi, > > > > I'd like to know how I create a pop-up, using .net, to populate it > > with variables that would be passed to my powershell script... > > > > thanks, > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| VBS Telnet to Server and Pass Variables for User and Password?? | VB Script | |||
| Include another script, keep variables in included script? | PowerShell | |||
| Outputting variables & accepting keystrokes without pressing enter | PowerShell | |||
| Need help with PHP Script variables | Network & Sharing | |||
| how do you pass named params to funcs by way of variables | PowerShell | |||