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?
Powershell

Avatar of undefined
Last Comment
jat0369

8/22/2022 - Mon
SOLUTION
Brent Challis

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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

jat0369

ASKER
Hi BChallis - any update to this? Any idea as to what I'm doing wrong?
ASKER CERTIFIED SOLUTION
jat0369

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23