Argument-completers have been around in a number of different forms since PowerShell 2. This section focuses on the implementation of argument-completers available in Windows PowerShell 5 and PowerShell Core.
An argument-completer is used by the tab completion system to provide a value for a parameter when Tab is pressed. For example, the Get-Module command cycles though module names when Tab is pressed after the command name. The argument-completer does not restrict the values that may be supplied; it is only used to offer values, to make the use of a command easier for an end user.
An argument-completer is a script block; the script block should accept the following parameters:
- commandName
- parameterName
- wordToComplete
- commandAst
- fakeBoundParameter
Any of these parameters may be used, but the most important and the most frequently used is wordToComplete...