Input a list of objects into array?

Product: PowerShell Universal
Version: 2.10.2

Is it possible to have a dashboard with an input that will accept a list of objects and bring it in as an array?

For example, a text box that could accept a list of servers pasted in, 1 server per line. I would be able to use the array in a foreach to iterate through the list afterwards. I tried New-UDTexbox -multiline but that didn’t seem to work or I am doing something wrong.

Thanks

You can use -Multiline for this. You just need to split by the new line character.

   New-UDForm -Children {
        New-UDTextbox -Id 'servers' -Multiline -Rows 10
    } -OnSubmit {
        $EventData.servers.split("`n") | % { Show-UDToast $_ }
    }

Cool thanks, now if I send to UDTable it only shows length?

New-UDForm -Children {
        New-UDTextbox -Id 'keys' -Multiline -rows 3
    } -OnSubmit {
        $test = $EventData.keys.split("`n")
        New-UDTable -Data $test
    }

image

Throw those bad boys in a hashtable. The issue is that it’s finding the Length property on the strings and using that as the column.

    New-UDForm -Children {
        New-UDTextbox -Id 'servers' -Multiline -Rows 10
    } -OnSubmit {
        $Data = $EventData.servers.split("`n") | % { 
            @{
                Name = $_ 
            }
        }

        New-UDTable -Data $data
    }
1 Like

Great thanks again!

2 Likes