I want to prompt for options from a programmatically generated list.
Background: I have 2 AWS accounts with containing different environments. The script automatically detects which account you are in, and then it should prompt for which environment you want to join.
I'm trying this:
$envs = "
1,Dev
1,Test
1,Demo
2,Staging
2,Production
" | ConvertFrom-Csv -Delimiter "," -header "awsAccount","Environment"
$awsAccount = Determine-awsAccount
$envs = ([string]($allServers.Environment | Where-Object -property awsAccount -eq $awsAccount | Sort-Object | Get-unique)).replace(" ",",")
$title = "Deploy into which environment"
$message = "Please select which environment you want to deploy into"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($envs)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
You can create a pop-up of options using
$options = [System.Management.Automation.Host.ChoiceDescription[]]("yes","no")
But in my case it's popping up one option containing all my environments, separated by commas. I want it to pop up one option for each (relevant) environment.
How can I pop the string list of environments back out from the in-PowerShell world to the outside-PowerShell world?
