Forum Discussion
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 the option select by the user from the drop down menu, it launch runs script 1 or script 2:
how to connect my two PowerShell scripts to these two drop down menu options?
any tutorial links will be greatly appreciated.
Thanks in advance everyone.
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_MorganIron 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
}