Forum Discussion
ShehzadUIT
May 30, 2019Brass Contributor
PowerShell: GUI programming - Combo boxes
Hi All, i am trying to build a simple GUI where users selects one of the two options from a drop down menu and click launch button. I have two PowerShell scripts. Scripts 1 and Script 2. Based on...
- May 30, 2019
In Launch button click, you have to get selected option and based on this option, you have to load your script file (assumed .ps1 file) and call the relevant function.
$scriptOption = #get selected dropdown item text
if($scriptOption -eq "Script1") {
#Initialize script1
. C:\Scripts\Script1.ps1
#Call function in script1
TestFunction
} else {
#Initialize script2
. C:\Scripts\Script2.ps1
#Call function in script2
TestFunction
}
Kevin_Morgan
May 30, 2019Iron Contributor
In Launch button click, you have to get selected option and based on this option, you have to load your script file (assumed .ps1 file) and call the relevant function.
$scriptOption = #get selected dropdown item text
if($scriptOption -eq "Script1") {
#Initialize script1
. C:\Scripts\Script1.ps1
#Call function in script1
TestFunction
} else {
#Initialize script2
. C:\Scripts\Script2.ps1
#Call function in script2
TestFunction
}