May 30 2019 04:47 AM
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.
May 30 2019 06:59 AM
Solution
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
}
May 30 2019 06:59 AM
Solution
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
}