Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Created March 1, 2019 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/8e31d823abcd889929412f6ed2b50c7a to your computer and use it in GitHub Desktop.
Save IISResetMe/8e31d823abcd889929412f6ed2b50c7a to your computer and use it in GitHub Desktop.
# define an argument completer
$completer = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
if($null -eq $script:_listOfArgCompletions){
# download list and populate $script:_listOfArgComplettions
$script:_listOfArgCompletions = @('Apples','Oranges','Nectarines')
}
$script:_listOfArgCompletions -like "$wordToComplete*" |ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_)
}
}
# register it
Register-ArgumentCompleter -CommandName Get-CustomThing -ParameterName Name -ScriptBlock $completer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment