convert array to enum

I have an array $computernames and need an enum [validComputernames]

The solution in the thread below is not working for me and seems outdated since PS5.0 added the enum Keyword.
https://powershell.org/forums/topic/create-enum-from-array/

Any ideas?

Ok, I found away using invoke-expression. Not very elegant but it works

$computernames = Get-content C:\Paul2018\Clients.txt

$exp = "Enum ValidComputernames{
    $(foreach ($name in $computernames){$name + ';'})
}"

Invoke-Expression $exp

How is your approach different / more efficient that what is documented here:
social.technet.microsoft.com/wiki/contents/articles/26436.how-to-create-and-use-enums-in-powershell.aspx