Exchange PowerShell dropdown issue -
i trying create drop down box in form set 2 text fields. when try add dropdown form changes end values, though not changing type or answer, changes value returns. original code wrote runs through perfect is:
function button ($title,$mailbx, $wf, $tf) { ###################load assembly creating form & button###### [void][system.reflection.assembly]::loadwithpartialname( “system.windows.forms”) [void][system.reflection.assembly]::loadwithpartialname( “microsoft.visualbasic”) #####define form size & placement $form = new-object “system.windows.forms.form”; $form.width = 750; $form.height = 500; $form.text = $title; $form.startposition = [system.windows.forms.formstartposition]::centerscreen; ##############define text label1 $textlabel1 = new-object “system.windows.forms.label”; $textlabel1.left = 25; $textlabel1.top = 15; $textlabel1.text = $mailbx; ##############define text label2 $textlabel2 = new-object “system.windows.forms.label”; $textlabel2.left = 25; $textlabel2.top = 50; $textlabel2.text = $wf; ##############define text label3 $textlabel3 = new-object “system.windows.forms.label”; $textlabel3.left = 25; $textlabel3.top = 85; $textlabel3.text = $tf; ############define text box1 input $textbox1 = new-object “system.windows.forms.textbox”; $textbox1.left = 150; $textbox1.top = 10; $textbox1.width = 200; ############define text box2 input $textbox2 = new-object “system.windows.forms.textbox”; $textbox2.left = 150; $textbox2.top = 50; $textbox2.width = 200; ############define text box3 input $textbox3 = new-object “system.windows.forms.textbox”; $textbox3.left = 150; $textbox3.top = 90; $textbox3.width = 200; #############define default values input boxes $defaultvalue = “” $textbox1.text = $defaultvalue; $textbox2.text = $defaultvalue; $textbox3.text = $defaultvalue; #############define ok button $button = new-object “system.windows.forms.button”; $button.left = 360; $button.top = 85; $button.width = 100; $button.text = “ok”; ############# when have close form after getting values $eventhandler = [system.eventhandler]{ $textbox1.text; $textbox2.text; $textbox3.text; $form.close();}; $button.add_click($eventhandler) ; #############add controls above objects defined $form.controls.add($button); $form.controls.add($textlabel1); $form.controls.add($textlabel2); $form.controls.add($textlabel3); $form.controls.add($textbox1); $form.controls.add($textbox2); $form.controls.add($textbox3); $ret = $form.showdialog(); #################return values return $textbox1.text, $textbox2.text, $textbox3.text } $return= button “enter info” “first name” “last name” “email address” $return2 = ($return[0] + " " + $return[1]) $return3 = ($return[0] + "." + $return[1]) $return4 = $return[0] + "." + $return[1] + "$return[2]" new-mailbox -alias $return3 -name $return2 -firstname $return[0] -lastname $return[1] -userprincipalname $return4 -password (convertto-securestring -string 'p@ssw0rd' -asplaintext -force) -resetpasswordonnextlogon $true set-user -identity $return3 -streetaddress '1600 pennsylvania ave nw' -city 'washington' -stateorprovince 'd.c.' -postalcode '20500' -phone '202-456-1111' -fax '202-456-2461'
the drop down code have
######################## # edit item change dropdown values [array]$dropdownarray = "@yahoo.com", "@gmail.com", "@lewisj.com" # function returns selected value , closes form function return-dropdown { $choice = $dropdown.selecteditem.tostring() } [system.reflection.assembly]::loadwithpartialname("system.windows.forms") [system.reflection.assembly]::loadwithpartialname("system.drawing") $dropdown = new-object system.windows.forms.combobox $dropdown.location = new-object system.drawing.size(400,10) $dropdown.size = new-object system.drawing.size(130,30) foreach ($item in $dropdownarray) { $dropdown.items.add($item) } $form.controls.add($dropdown) $dropdownlabel = new-object system.windows.forms.label $dropdownlabel.location = new-object system.drawing.size(10,10) $dropdownlabel.size = new-object system.drawing.size(100,20) $dropdownlabel.text = "items" $form.controls.add($dropdownlabel) $button = new-object system.windows.forms.button $button.location = new-object system.drawing.size(100,50) $button.size = new-object system.drawing.size(100,20) $button.text = "ok" $button.add_click({return-dropdown}) $form.controls.add($button)
i trying have if enter first name ben, last name don, , use drop down feature , select @gmail.com. return values. when tried combine 2 codes changed values :
system.windows.forms, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089 system.drawing, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d5 0a3a system.windows.forms, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.system.drawing, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d5 0a3a system.windows.forms, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.system.drawing, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d5 0a3a0
anyone know how drop down correct?
it seems once again in need of voiding return values methods in code. if @ technet list box (yes know have drop down) see on top of voiding
[void][system.reflection.assembly]::loadwithpartialname("system.windows.forms") [void][system.reflection.assembly]::loadwithpartialname("system.drawing")
you have address add
method well.
[void]$dropdown.items.add($item)
that should ensure returns ones want. might still have issue value drop down in right direction.
Comments
Post a Comment