sthArgumentCompleter - is a module for managing argument completers registered by Register-ArgumentCompleter cmdlet.
It contains following functions:
Get-CustomArgumentCompleter - Gets registered custom argument completers.
Get-NativeArgumentCompleter - Gets registered native argument completers.
Get-CustomArgumentCompleterScriptBlock - Gets scriptblock of the registered custom argument completer.
Get-NativeArgumentCompleterScriptBlock - Gets scriptblock of the registered native argument completer.
Remove-CustomArgumentCompleter - Removes specified registered custom argument completers.
Remove-NativeArgumentCompleter - Removes specified registered native argument completers.
Clear-CustomArgumentCompleters - Clears all of the registered custom argument completers.
Clear-NativeArgumentCompleters - Clears all of the registered native argument completers.
You can install sthArgumentCompleter module from PowerShell Gallery:
Install-Module sthArgumentCompleter
The command gets all custom argument completers registered in the current session.
Get-CustomArgumentCompleter
CommandName ParameterName ScriptBlock
----------- ------------- -----------
Get-Something Name …
Do-Something Action …
SomeParameter …
The command gets specified custom argument completer.
Get-CustomArgumentCompleter -Name Get-Something:Name
CommandName ParameterName ScriptBlock
----------- ------------- -----------
Get-Something Name …
The command gets specified custom argument completer and expands its scriptblock.
Get-CustomArgumentCompleter -Name Get-Something:Name -ExpandScriptBlocks
CommandName ParameterName ScriptBlock
----------- ------------- -----------
Get-Something Name
$names = 'NameOne', 'NameTwo', 'NameThree'
foreach ($name in $names)
{
if ($name -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($name)
}
}
The command gets all native argument completers registered in the current session.
Get-NativeArgumentCompleter
CommandName ScriptBlock
----------- -----------
somecommand …
anothercommand …
The command gets specified native argument completer.
Get-NativeArgumentCompleter -Name somecommand
CommandName ScriptBlock
----------- -----------
somecommand …
The command gets specified native argument completer and expands its scriptblock.
Get-NativeArgumentCompleter -Name somecommand -ExpandScriptBlocks
CommandName ScriptBlock
----------- -----------
somecommand
$arguments = 'ArgumentOne', 'ArgumentTwo', 'ArgumentThree'
foreach ($argument in $arguments)
{
if ($argument -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($argument)
}
}
The command gets scriptblock of the specified custom argument completer.
Get-CustomArgumentCompleterScriptBlock -Name Get-Something:Name
$names = 'NameOne', 'NameTwo', 'NameThree'
foreach ($name in $names)
{
if ($name -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($name)
}
}
The command gets scriptblock of the custom argument completer sent through the pipeline.
Get-CustomArgumentCompleter -Name Do-Something:Action | Get-CustomArgumentCompleterScriptBlock
$actions = 'ActionOne', 'ActionTwo'
foreach ($action in $actions)
{
if ($action -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($action)
}
}
The command gets scriptblock of the specified native argument completer.
Get-NativeArgumentCompleterScriptBlock -Name somecommand
$arguments = 'ArgumentOne', 'ArgumentTwo', 'ArgumentThree'
foreach ($argument in $arguments)
{
if ($argument -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($argument)
}
}
The command gets scriptblock of the native argument completer sent through the pipeline.
Get-NativeArgumentCompleter -Name anothercommand | Get-NativeArgumentCompleterScriptBlock
$arguments = 'ArgumentOne', 'ArgumentTwo'
foreach ($argument in $arguments)
{
if ($argument -like "$wordToComplete*")
{
[System.Management.Automation.CompletionResult]::new($argument)
}
}
The command removes specified custom argument completer.
Remove-CustomArgumentCompleter -Name Get-Something:Name
The command removes custom argument completer sent through the pipeline.
Get-CustomArgumentCompleter -Name Do-Something:Action | Remove-CustomArgumentCompleter
The command removes specified native argument completer.
Remove-NativeArgumentCompleter -Name somecommand
The command removes native argument completer sent through the pipeline.
Get-NativeArgumentCompleter -Name anothercommand | Remove-NativeArgumentCompleter
The command clears all of the registered custom argument completers.
Clear-CustomArgumentCompleters
The command clears all of the registered native argument completers.
Clear-NativeArgumentCompleters