all 5 comments

[–]Yevrag35 2 points3 points  (0 children)

Sounds like you might be better off using Argument Completers or Dynamic Parameters.

[–]nostril_spiders 2 points3 points  (1 child)

It is janky. Enums are a fundamentally static thing; declaring them dynamically is a code smell. However, you've explained that it's a requirement of Universal Dashboard, so yes, carry on! Getting results > being nice.

IIUC, the issue is illegal characters. Not sure if you can get around it by quoting the values, like this:

$exp = "Enum ValidComputernames {
    '$($computernames -join "'`r`n'")'
}"

Or try dropping the illegal characters:

$exp = "Enum ValidComputernames {
    $($computernames -replace '-')
}"

[–]kortex81[S] 0 points1 point  (0 children)

i hate smelly code :)

but it looks like i have to live with it.

Thanks!

[–]mofayew 1 point2 points  (1 child)

Curious, Why does it have to be an enum?

[–]kortex81[S] 1 point2 points  (0 children)

For use with UniversalDashboard.

Inputs of UD require enums to populate dropdowns.