Author Posts

January 5, 2018 at 6:40 pm

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

January 5, 2018 at 7:32 pm

I figured it out. Add the [] within the EnumName type for the param. 😀

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