Link to home
Start Free TrialLog in
Avatar of jat0369
jat0369

asked on

Create Dropdown and pass selection back to script

I have a script that builds a CSV file (Name, Description).

I'd like to have some sort of pop-up occur that has a dropdown of only one of the collumns. Once the item is selected and the user clicks okay, it sends that variable back to the script for further processing.  I'm at a loss of how to go about doing this.   Would someone please help me out and show me a simple example of how to do this?
SOLUTION
Avatar of Brent Challis
Brent Challis
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jat0369
jat0369

ASKER

This is exactly what I'm looking for. Great work!
I took the SelectItemFromList.txt and renamed it dropdown.ps1
I referenced the file and called the function and It's giving me a bit of a problem. What am I doing wrong?

PS C:\Install\POS_PREP> $thisScript = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
PS C:\Install\POS_PREP> . ($thisScript + '.\dropdown.ps1')
PS C:\Install\POS_PREP> Select-ItemFromList -option "One","Two","Three" -mode Menu -selectionMode None
Unable to find type [System.Windows.Forms.SelectionMode]: make sure that the assembly containing this type is loaded.
At C:\Install\POS_PREP\dropdown.ps1:73 char:41
+     [System.Windows.Forms.SelectionMode] <<<< $selectionMode = [System.Windows.Forms.SelectionMode]::One
    + CategoryInfo          : InvalidOperation: (System.Windows.Forms.SelectionMode:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

PS C:\Install\POS_PREP>

Open in new window

Avatar of jat0369

ASKER

Hi BChallis - any update to this? Any idea as to what I'm doing wrong?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jat0369

ASKER

I ended up solving the issue myself using the code supplied. It's not as clean as the version bchallis supplied, but it works.