PowerShell completion scripts for managed registrations, runtime discovery, and safe removal.
CompleterActions is a PowerShell 7+ / Core-only module for registering, discovering, querying, and removing PowerShell argument completers in a consistent way.
Important
This module targets PowerShell 7+ / PowerShell Core only. The manifest declares CompatiblePSEditions = @('Core') and PowerShellVersion = '7.0'.
- Manage both parameter completers and native command completers
- Import supported completer scripts into managed registration input objects
- Query module-managed registrations and runtime-discovered registrations
- Remove managed registrations cleanly from both runtime and module state
- Require explicit opt-in before removing unmanaged runtime registrations
- Return rich registration objects with default table formatting
- Support property-name pipeline binding and paging for discovery scenarios
| Command | What it does |
|---|---|
Get-CompleterRegistration |
Lists completer registrations known to the module or discovered from the current runtime |
Import-CompleterScript |
Converts supported standalone completer scripts into objects that can be piped to Register-CompleterRegistration -InputObject |
Register-CompleterRegistration |
Registers a managed completer and records it in module state |
Unregister-CompleterRegistration |
Removes completer registrations from runtime and, when applicable, from module state |
Install-PSResource -Name CompleterActions
Import-Module CompleterActionsImport-Module .\CompleterActions.psd1Import-Module .\build\CompleterActions\CompleterActions.psd1Get-Help about_Import_CompletersRuntime registration discovery and unmanaged-registration removal depend on PowerShell runtime internals. The module is tested on PowerShell 7, but future engine changes may require maintenance in that discovery path.
- Register a completer directly, or import an existing completer script into managed input objects.
- Inspect registrations with
Get-CompleterRegistration. - Replace or remove registrations when the target changes.
- Use
-AllowUnmanagedonly when removing runtime registrations that were not created by the module.
function Invoke-DemoTool {
[CmdletBinding()]
param(
[string] $Name
)
}
$scriptBlock = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
'alpha', 'beta', 'gamma' |
Where-Object { $_ -like "$wordToComplete*" } |
ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Register-CompleterRegistration -CommandName Invoke-DemoTool -ParameterName Name -ScriptBlock $scriptBlock$nativeScriptBlock = {
param($wordToComplete, $commandAst, $cursorPosition)
'status', 'switch', 'sync' |
Where-Object { $_ -like "$wordToComplete*" } |
ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Register-CompleterRegistration -CommandName demoexe -Native -ScriptBlock $nativeScriptBlockImport-CompleterScript -Path .\7z_completer.ps1 |
Register-CompleterRegistration -PassThru# All known registrations
Get-CompleterRegistration
# A specific native completer
Get-CompleterRegistration -CommandName git -Native
# A specific parameter completer
Get-CompleterRegistration -CommandName Invoke-DemoTool -ParameterName Name
# Only module-managed registrations
Get-CompleterRegistration -ManagedOnly
# Only runtime-discovered registrations
Get-CompleterRegistration -DiscoveredOnlyRegister-CompleterRegistration `
-CommandName Invoke-DemoTool `
-ParameterName Name `
-ScriptBlock $scriptBlock `
-Force# Remove a managed registration
Unregister-CompleterRegistration -CommandName Invoke-DemoTool -ParameterName Name -Confirm:$false
# Remove by key
Get-CompleterRegistration -CommandName demoexe -Native |
Unregister-CompleterRegistration -Confirm:$false
# Remove a runtime-only registration explicitly
Unregister-CompleterRegistration `
-CommandName SomeTool `
-ParameterName Name `
-AllowUnmanaged `
-Confirm:$falseRegistration records use the CompleterActions.CompleterRegistration type and have a default table view with:
CommandParameterTypeSource
Get-CompleterRegistration supports PowerShell paging parameters, so you can do things like:
Get-CompleterRegistration -First 10
Get-CompleterRegistration -Skip 10 -First 10 -IncludeTotalCountPipeline highlights:
Get-CompleterRegistrationsupports property-name binding for key, command, and parameter lookupsImport-CompleterScriptemits input objects that are ready forRegister-CompleterRegistration -InputObjectRegister-CompleterRegistrationcan accept input objects that describe a target and expose aScriptBlockUnregister-CompleterRegistrationcan accept pipeline input directly fromGet-CompleterRegistration
Example:
Get-CompleterRegistration -ManagedOnly |
Unregister-CompleterRegistration -Confirm:$falseThe repository uses Invoke-Build.
Invoke-Build -Task clean
Invoke-Build -Task build
Invoke-Build -Task external_help
Invoke-Build -Task Markdown_templates
Invoke-Build -Task ?The repository uses Pester.
Invoke-PesterThe repository includes PSScriptAnalyzerSettings.psd1.
Invoke-ScriptAnalyzer -Path .\src -Settings .\PSScriptAnalyzerSettings.psd1
Invoke-ScriptAnalyzer -Path .\CompleterActions.psm1 -Settings .\PSScriptAnalyzerSettings.psd1CompleterActions.psd1is the root manifest and defines the exported public functions, formatting file, and PowerShell/Core compatibility.CompleterActions.psm1is a lightweight root loader that dot-sourcessrc\Privateandsrc\Public, initializes module state, and exports the public function set.src\Publiccontains the user-facing command surface:Get-CompleterRegistrationImport-CompleterScriptRegister-CompleterRegistrationUnregister-CompleterRegistration
src\Privatecontains the runtime and state helpers that resolve targets, manage the module registration table, and inspect or remove runtime registrations.
The module discovers live completer registrations by reflecting into PowerShell runtime internals to access the underlying completer dictionaries. That makes the current implementation practical and useful, but it also means runtime discovery depends on non-public engine details and may need maintenance if PowerShell internals change in a future release.
- Managed registrations are tracked in module state for the current session.
- Runtime-discovered registrations can be queried even if they were not created by this module.
- Removal of unmanaged runtime registrations is intentionally gated behind
-AllowUnmanaged.
