February 2019
Intermediate to advanced
626 pages
15h 51m
English
The argument-completer attribute is used much like ValidateScript. The script block used previously is used as an argument for the attribute, shown as follows:
function Test-ArgumentCompleter { [CmdletBinding()] param ( [Parameter(Mandatory)] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter ) $possibleValues = 'Start', 'Stop', 'Create', 'Delete' $possibleValues | Where-Object { $_ -like "$wordToComplete*" } } )] $Action )}
When the user types Test-ArgumentCompleter and then presses Tab, the completer offers up each of the possible values with no filtering. If the user were to type Test-ArgumentCompleters, only start and stop would be offered when ...
Read now
Unlock full access