Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AndyBodnar
Copy link

PR Summary

Hey, this adds the Get-ArgumentCompleter and Unregister-ArgumentCompleter cmdlets that were discussed in #25800. The WG approved adding these back in October 2025 and I noticed the issue was still open, so I figured I'd take a crack at it.

Right now if you register argument completers, there's no way to see what's registered or remove them without restarting your session (or using the null trick with Register-ArgumentCompleter). These two cmdlets fix that.

Get-ArgumentCompleter lets you see all the registered completers. You can filter by command name, parameter name, or use the -Native switch to see native command completers. Wildcards work too, so you can do stuff like Get-ArgumentCompleter -CommandName "Get-*" to find completers for all Get commands.

Unregister-ArgumentCompleter removes completers. I matched the parameter sets to Register-ArgumentCompleter so they feel consistent. You can unregister by command+parameter for PowerShell completers, by command name for native completers, or use -NativeFallback to remove the fallback completer.

I also added an ArgumentCompleterInfo class that Get-ArgumentCompleter returns, and an ArgumentCompleterType enum so you can easily tell if something is a PowerShell completer, native completer, or the native fallback.

PR Context

Fixes #25800

PR Checklist

This change adds two new cmdlets to complement the existing Register-ArgumentCompleter cmdlet:

- Get-ArgumentCompleter: Returns registered argument completers with filtering support for command name, parameter name, and native vs PowerShell completers. Supports wildcards.

- Unregister-ArgumentCompleter: Removes registered argument completers. Mirrors the parameter sets of Register-ArgumentCompleter for consistency.

Also adds ArgumentCompleterInfo class and ArgumentCompleterType enum to expose completer information, and includes tests for the new cmdlets.

Fixes PowerShell#25800
@AndyBodnar AndyBodnar requested a review from a team as a code owner January 11, 2026 21:20
@iSazonov
Copy link
Collaborator

Some thoughts.
We have the opportunity to register one completer for several cmdlets. I would expect that the new cmdlets are more focused on completers.
For example, get a list of all the completers and their corresponding list of commands; for a given cmdlet, show the completer and all the commands to which it is linked.
This is the same approach I would expect from unregistering.

@AndyBodnar
Copy link
Author

Hey, thanks for the feedback! Yeah I see your point about one completer potentially being registered to multiple commands - that's a fair observation.

The reason I went with the command-centric approach is because it kinda mirrors how Register-ArgumentCompleter already works, right? You register a completer for a specific command/parameter combo. So it felt natural for Get-ArgumentCompleter to query along those same lines.

Also from a user perspective I figured most people would be thinking "what completers are registered on Get-Process" rather than "show me all commands using this particular scriptblock". At least thats how I tend to think about it when debugging completion issues.

That said, I'm totally open to adding something like a -Completer parameter or maybe a grouping option if you think that would be more useful for the scenarios you have in mind. What would you prefer - should I add that as an additional parameter, or were you thinking of a different approach entirely?

@iSazonov
Copy link
Collaborator

The reason I went with the command-centric approach is because it kinda mirrors how Register-ArgumentCompleter already works, right? You register a completer for a specific command/parameter combo. So it felt natural for Get-ArgumentCompleter to query along those same lines.

Notice, Register-ArgumentCompleter allows registering one completer for some commands. So Get-ArgumentCompleter should be able to show the information. I don't know that is best solution. We need more discussion in related issue.

@AndyBodnar
Copy link
Author

anyone available to review this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding Get-ArgumentCompleter and Unregister-ArgumentCompleter for custom completer management

2 participants