Default values set for $param in advanced function

  • How can I specify a list of values for an advanced function?
    For example, I want to write a function with a parameter called $ReportingPeriod. I only want to allow 5 selections to be allowed.
    More to the point, I'd like them to be selectable in a drop-down in the call. Something similar to what you see when you type
    add-content -encoding
    when  you hit the space after "-encoding", a list of possible selections is displayed

  • Don't know why this was SO hard to find...
    FYI: I understand there is an Enum function? command? in PoSh V5.

    Add-Type -TypeDefinition @"
     // very simple enum type
     public enum ReportingPeriods
     {
             All,
          Yesterday,
            CurrentWeek,
            PreviousWeek,
            MonthToDate,
            LastMonth,
            YearToDate
     }
    "@

    [ReportingPeriods]::

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply