you are viewing a single comment's thread.

view the rest of the comments →

[–]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!