Skip to content

Commit

Permalink
(GH-11248) Clarify behavior for Register-ArgumentCompleter parameters
Browse files Browse the repository at this point in the history
Prior to this change, the `Register-ArgumentCompleter` reference didn't indicate that
specifying the **CommandName** parameter without the **ParameterName** or **Native**
parameters causes the command to behave as if the user specified the `-Native` switch.

This change:

- Clarifies that users should always specify the **ParameterName** parameter when
  registering an argument completer for a PowerShell command.
- Resolves #11248
- Fixes AB#281953
  • Loading branch information
michaeltlombardi committed Jul 10, 2024
1 parent ed340fb commit 2f9a014
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/09/2022
ms.date: 07/10/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Register-ArgumentCompleter
Expand Down Expand Up @@ -36,6 +36,12 @@ The `Register-ArgumentCompleter` cmdlet registers a custom argument completer. A
completer allows you to provide dynamic tab completion, at run time for any command that you
specify.

When you call this command with the **CommandName** parameter and without the **ParameterName** or
**Native** parameters, the command runs as if you specified the **Native** parameter. This prevents
the argument completer from working for PowerShell command parameters. Always specify the
**ParameterName** parameter when you want to register an argument completer for a PowerShell
command.

## EXAMPLES

### Example 1: Register a custom argument completer
Expand Down Expand Up @@ -182,6 +188,10 @@ cannot be an enumerated value, such as the **ForegroundColor** parameter of the

For more information on enums, see [about_Enum](./About/about_Enum.md).

When registering an argument completer for a specific PowerShell command, always specify this
parameter. When you specify the **CommandName** parameter without the **ParameterName** or
**Native** parameters, the command behaves as if you specified the **Native** parameter.

```yaml
Type: System.String
Parameter Sets: PowerShellSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/09/2022
ms.date: 07/10/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Register-ArgumentCompleter
Expand Down Expand Up @@ -36,6 +36,12 @@ The `Register-ArgumentCompleter` cmdlet registers a custom argument completer. A
completer allows you to provide dynamic tab completion, at run time for any command that you
specify.

When you call this command with the **CommandName** parameter and without the **ParameterName** or
**Native** parameters, the command runs as if you specified the **Native** parameter. This prevents
the argument completer from working for PowerShell command parameters. Always specify the
**ParameterName** parameter when you want to register an argument completer for a PowerShell
command.

## EXAMPLES

### Example 1: Register a custom argument completer
Expand Down Expand Up @@ -182,6 +188,10 @@ cannot be an enumerated value, such as the **ForegroundColor** parameter of the

For more information on enums, see [about_Enum](./About/about_Enum.md).

When registering an argument completer for a specific PowerShell command, always specify this
parameter. When you specify the **CommandName** parameter without the **ParameterName** or
**Native** parameters, the command behaves as if you specified the **Native** parameter.

```yaml
Type: System.String
Parameter Sets: PowerShellSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/09/2022
ms.date: 07/10/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Register-ArgumentCompleter
Expand Down Expand Up @@ -36,6 +36,12 @@ The `Register-ArgumentCompleter` cmdlet registers a custom argument completer. A
completer allows you to provide dynamic tab completion, at run time for any command that you
specify.

When you call this command with the **CommandName** parameter and without the **ParameterName** or
**Native** parameters, the command runs as if you specified the **Native** parameter. This prevents
the argument completer from working for PowerShell command parameters. Always specify the
**ParameterName** parameter when you want to register an argument completer for a PowerShell
command.

## EXAMPLES

### Example 1: Register a custom argument completer
Expand Down Expand Up @@ -182,6 +188,10 @@ cannot be an enumerated value, such as the **ForegroundColor** parameter of the

For more information on enums, see [about_Enum](./About/about_Enum.md).

When registering an argument completer for a specific PowerShell command, always specify this
parameter. When you specify the **CommandName** parameter without the **ParameterName** or
**Native** parameters, the command behaves as if you specified the **Native** parameter.

```yaml
Type: System.String
Parameter Sets: PowerShellSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/09/2022
ms.date: 07/10/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Register-ArgumentCompleter
Expand Down Expand Up @@ -36,6 +36,12 @@ The `Register-ArgumentCompleter` cmdlet registers a custom argument completer. A
completer allows you to provide dynamic tab completion, at run time for any command that you
specify.

When you call this command with the **CommandName** parameter and without the **ParameterName** or
**Native** parameters, the command runs as if you specified the **Native** parameter. This prevents
the argument completer from working for PowerShell command parameters. Always specify the
**ParameterName** parameter when you want to register an argument completer for a PowerShell
command.

## EXAMPLES

### Example 1: Register a custom argument completer
Expand Down Expand Up @@ -182,6 +188,10 @@ cannot be an enumerated value, such as the **ForegroundColor** parameter of the

For more information on enums, see [about_Enum](./About/about_Enum.md).

When registering an argument completer for a specific PowerShell command, always specify this
parameter. When you specify the **CommandName** parameter without the **ParameterName** or
**Native** parameters, the command behaves as if you specified the **Native** parameter.

```yaml
Type: System.String
Parameter Sets: PowerShellSet
Expand Down

0 comments on commit 2f9a014

Please sign in to comment.