Ordering of script


Im writing a set of PS scripts using informs and information is passed between scripts and the majority is working fine.

but on my main form that is the one that initiates the tool, i have a drop down box which gets populated with server environements to allow you which environment you want the tool to be focused on. The functionality works fine, but only after a second launch of the tool. So its clearly something to do with the ordering of the script that isn’t quite right, because if i clear the session down, launch the tool, then select the environment from the list nothing happens. Close the tool, launch again and everything works as expected.

All the code for the main form is within a single script, which is the launch script. All the code is above the the forms.showdialog() command, and the event actions are below the join-path statements so i can’t see why its not failing.

The event code for the drop down is as follows:

comboBox_ValueSelected {
$sessionEnvironment = $combobox.text
Call-Function xxxx -environment $sessionEnvironment

but selecting a value from the combo box does nothing on the first launch.

Tool: Visual Studio, Visual Studio Code, PSScriptPad, PowerShell Module