From 3f3cbea5687f9b846248b602d8b0c9d87d77295b Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 10 Apr 2025 13:23:37 +0100 Subject: [PATCH] Fixes description of __AllParameterSets and ValueFromPipeline in about_Parameter_Sets (#11986) * Fixes about_Parameter_Sets * Clarify `DefaultParameterSetName` usage in documentation * minor edit --------- Co-authored-by: Sean Wheeler --- .../About/about_Parameter_Sets.md | 22 ++++++++++--------- .../About/about_Parameter_Sets.md | 22 ++++++++++--------- .../About/about_Parameter_Sets.md | 22 ++++++++++--------- .../About/about_Parameter_Sets.md | 22 ++++++++++--------- 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md index b11ed8d1bdce..0aabc51c4fb1 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md @@ -33,10 +33,6 @@ The following requirements apply to all parameter sets. unique positions for each parameter. No two positional parameters can specify the same position. -- Only one parameter in a set can declare the `ValueFromPipeline` keyword with - a value of `true`. Multiple parameters can define the - `ValueFromPipelineByPropertyName` keyword with a value of `true`. - > [!NOTE] > There is a limit of 32 parameter sets. @@ -69,12 +65,18 @@ parameter sets. PowerShell reserves the parameter set name `__AllParameterSets` for special handling. -- This name is the default name of the parameter set that when you don't - explicitly define a parameter set name. -- When you have muliple parameter sets, you can use this name to define a - parameter that belongs to all parameter sets. -- Setting **DefaultParameterSetName** to `__AllParameterSets` in the - `[CmdletBinding()]` attribute has no effect. +`__AllParameterSets` is the name of the default parameter set when an explicit +default name is not used. + +Setting the `ParameterSetName` of a the **Parameter** attribute to +`__AllParameterSets` is equivalent to not assigning a `ParameterSetName`. In +both cases the parameter belongs to all parameter sets. + +> [!NOTE] +> The **CmdletBinding** attribute doesn't prevent you from setting the +> `DefaultParameterSetName` to be to `__AllParameterSets`. If you do this, +> PowerShell creates an explicit parameter set that can't be properly +> referenced by the **Parameter** attribute. ## Examples diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md index 861f4859b251..d0e3149f8386 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md @@ -33,10 +33,6 @@ The following requirements apply to all parameter sets. unique positions for each parameter. No two positional parameters can specify the same position. -- Only one parameter in a set can declare the `ValueFromPipeline` keyword with - a value of `true`. Multiple parameters can define the - `ValueFromPipelineByPropertyName` keyword with a value of `true`. - > [!NOTE] > There is a limit of 32 parameter sets. @@ -69,12 +65,18 @@ parameter sets. PowerShell reserves the parameter set name `__AllParameterSets` for special handling. -- This name is the default name of the parameter set that when you don't - explicitly define a parameter set name. -- When you have muliple parameter sets, you can use this name to define a - parameter that belongs to all parameter sets. -- Setting **DefaultParameterSetName** to `__AllParameterSets` in the - `[CmdletBinding()]` attribute has no effect. +`__AllParameterSets` is the name of the default parameter set when an explicit +default name is not used. + +Setting the `ParameterSetName` of a the **Parameter** attribute to +`__AllParameterSets` is equivalent to not assigning a `ParameterSetName`. In +both cases the parameter belongs to all parameter sets. + +> [!NOTE] +> The **CmdletBinding** attribute doesn't prevent you from setting the +> `DefaultParameterSetName` to be to `__AllParameterSets`. If you do this, +> PowerShell creates an explicit parameter set that can't be properly +> referenced by the **Parameter** attribute. ## Examples diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md index cfbd15ffd8e6..9152b870030e 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md @@ -33,10 +33,6 @@ The following requirements apply to all parameter sets. unique positions for each parameter. No two positional parameters can specify the same position. -- Only one parameter in a set can declare the `ValueFromPipeline` keyword with - a value of `true`. Multiple parameters can define the - `ValueFromPipelineByPropertyName` keyword with a value of `true`. - > [!NOTE] > There is a limit of 32 parameter sets. @@ -69,12 +65,18 @@ parameter sets. PowerShell reserves the parameter set name `__AllParameterSets` for special handling. -- This name is the default name of the parameter set that when you don't - explicitly define a parameter set name. -- When you have muliple parameter sets, you can use this name to define a - parameter that belongs to all parameter sets. -- Setting **DefaultParameterSetName** to `__AllParameterSets` in the - `[CmdletBinding()]` attribute has no effect. +`__AllParameterSets` is the name of the default parameter set when an explicit +default name is not used. + +Setting the `ParameterSetName` of a the **Parameter** attribute to +`__AllParameterSets` is equivalent to not assigning a `ParameterSetName`. In +both cases the parameter belongs to all parameter sets. + +> [!NOTE] +> The **CmdletBinding** attribute doesn't prevent you from setting the +> `DefaultParameterSetName` to be to `__AllParameterSets`. If you do this, +> PowerShell creates an explicit parameter set that can't be properly +> referenced by the **Parameter** attribute. ## Examples diff --git a/reference/7.6/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md b/reference/7.6/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md index b6469444b627..7abc47c31570 100644 --- a/reference/7.6/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md +++ b/reference/7.6/Microsoft.PowerShell.Core/About/about_Parameter_Sets.md @@ -33,10 +33,6 @@ The following requirements apply to all parameter sets. unique positions for each parameter. No two positional parameters can specify the same position. -- Only one parameter in a set can declare the `ValueFromPipeline` keyword with - a value of `true`. Multiple parameters can define the - `ValueFromPipelineByPropertyName` keyword with a value of `true`. - > [!NOTE] > There is a limit of 32 parameter sets. @@ -69,12 +65,18 @@ parameter sets. PowerShell reserves the parameter set name `__AllParameterSets` for special handling. -- This name is the default name of the parameter set that when you don't - explicitly define a parameter set name. -- When you have muliple parameter sets, you can use this name to define a - parameter that belongs to all parameter sets. -- Setting **DefaultParameterSetName** to `__AllParameterSets` in the - `[CmdletBinding()]` attribute has no effect. +`__AllParameterSets` is the name of the default parameter set when an explicit +default name is not used. + +Setting the `ParameterSetName` of a the **Parameter** attribute to +`__AllParameterSets` is equivalent to not assigning a `ParameterSetName`. In +both cases the parameter belongs to all parameter sets. + +> [!NOTE] +> The **CmdletBinding** attribute doesn't prevent you from setting the +> `DefaultParameterSetName` to be to `__AllParameterSets`. If you do this, +> PowerShell creates an explicit parameter set that can't be properly +> referenced by the **Parameter** attribute. ## Examples