Search code examples
c#powershelltabexpansion

PowerShell - Parameter Value Tab Expansion for Enum types


Is it possible to implement parameter value tab expansion for enum parameter types?

Creating a binary cmdlet with parameter definition:

[Parameter]
public SomeEnum Type {get;set;} 

Is there some way to type:

Add-MyThing -Type S<tab> 

To get:

Add-MyThing -Type SomeEnumValue

Where:

public enum SomeEnum 
{
   SomeEnumValue,
   SomeEnumValue2
}

I know it may be possible with overriding the TabExpansion function but I was wondering if there was something I could do within my cmdlet to expose this type of functionality.


Solution

  • Parameter parsing and tab-completion are handled by PowerShell. The only extensibility hook for tab-completion is the TabExpansion function you mentioned.