Forum Discussion

ShehzadUIT's avatar
ShehzadUIT
Brass Contributor
May 30, 2019
Solved

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...
  • Kevin_Morgan's avatar
    May 30, 2019

    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
    }

Resources