SOLVED

PowerShell: GUI programming - Combo boxes

Brass Contributor

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:

 

IM8.JPG

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.

1 Reply
best response confirmed by ShehzadUIT (Brass Contributor)
Solution

@ShehzadUIT 

 

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
}
1 best response

Accepted Solutions
best response confirmed by ShehzadUIT (Brass Contributor)
Solution

@ShehzadUIT 

 

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
}

View solution in original post