powershell - In validateset is it possible to pass the contents of the file? -


in script , passing list of components need taken build

    [validateset("instalcomponent","corecomponent","sdkcomponent","servicecomponent","timecomponent")]    $components=@("instalcomponent","corecomponent"), 

from time time adding new component , list long. if there way passing via file "get-content components.txt". of good. there way set this?

one option create [enum] file contents, cast parameter type:

@(    "instalcomponent",    "corecomponent",    "sdkcomponent",    "servicecomponent",    "timecomponent") |     set-content components.txt   add-type -typedefinition @"    public enum mycomponents    {      $(((get-content .\components.txt) -join ', ').split())    } "@  function test {   param ( [mycomponents[]]$components)   $components } 

creating , using enums in powershell


Comments