Function with Enum values for ValidateSet parameter

Hey all,

I built an enum with a lot of values with hopes that I could use the values of the enum within a [ValidateSet([EnumName])], but it doesn’t work. If I do the following below, the Enum values are available, but if I use multiple values like such Get-Something -Value v1,v2,v3 the right values do not get passed into the function.

If I only pass in 1 value “Get-something -value v1” then the function works correctly.

What am I missing?

function Get-Something {
  [CmdletBinding()]
  param(
    [EnumName]
    [String[]]
    $Value  
  )
}

Thanks,
Michael

I figured it out. Add the within the EnumName type for the param. :smiley:

function Get-Something {
  [CmdletBinding()]
  param(
    [EnumName[]]
    $Value  
  )
}