Wednesday, October 4, 2017

Powershell, Adding Autocomplete to a Function

tldr: Add the ValidateSet attribute to a parameter. Like this: [ValidateSet("value 1", "value 2", "value etc")]$parameter or more verbosely:
function Get-Something(
    ValidateSet("value 1", "value 2", "value etc")]
    $parameter) {
    Write-Host "hi"
}
Just figured that out. Much bigger post here.