diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md index 49202f725f72..9f52147f0299 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md @@ -1,7 +1,7 @@ --- description: Explains how to add parameters to advanced functions. Locale: en-US -ms.date: 01/04/2025 +ms.date: 01/06/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Functions_Advanced_Parameters @@ -640,6 +640,28 @@ displayed in the `Get-Help -Full` output. This argument has no effect on optional parameters. +#### DontShow argument + +The `DontShow` value is typically used to assist backwards compatibility for a +command where an obsolete parameter cannot be removed. Setting `DontShow` to +`True` hides the parameter from the user for tab expansion and IntelliSense. + +PowerShell v7 (and higher) uses `DontShow` to hide the following obsolete +parameters: + +- The **NoTypeInformation** parameter of `ConvertTo-Csv` and `Export-Csv` +- The **Raw** parameter of `Format-Hex` +- The **UseBasicParsing** parameter of `Invoke-RestMethod` and + `Invoke-WebRequest` + +The `DontShow` argument has the following side effects: + +- Affects all parameter sets for the associated parameter, even if there's a + parameter set in which `DontShow` is unused. +- Hides common parameters from tab completion and IntelliSense. `DontShow` + doesn't hide the optional common parameters: **WhatIf**, **Confirm**, or + **UseTransaction**. + ### Alias attribute The **Alias** attribute establishes an alternate name for the parameter. diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md index eceb10fdf650..dd249ae0fa77 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md @@ -1,7 +1,7 @@ --- description: Explains how to add parameters to advanced functions. Locale: en-US -ms.date: 01/04/2025 +ms.date: 01/06/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Functions_Advanced_Parameters @@ -629,6 +629,28 @@ displayed in the `Get-Help -Full` output. This argument has no effect on optional parameters. +#### DontShow argument + +The `DontShow` value is typically used to assist backwards compatibility for a +command where an obsolete parameter cannot be removed. Setting `DontShow` to +`True` hides the parameter from the user for tab expansion and IntelliSense. + +PowerShell v7 (and higher) uses `DontShow` to hide the following obsolete +parameters: + +- The **NoTypeInformation** parameter of `ConvertTo-Csv` and `Export-Csv` +- The **Raw** parameter of `Format-Hex` +- The **UseBasicParsing** parameter of `Invoke-RestMethod` and + `Invoke-WebRequest` + +The `DontShow` argument has the following side effects: + +- Affects all parameter sets for the associated parameter, even if there's a + parameter set in which `DontShow` is unused. +- Hides common parameters from tab completion and IntelliSense. `DontShow` + doesn't hide the optional common parameters: **WhatIf**, **Confirm**, or + **UseTransaction**. + ### Alias attribute The **Alias** attribute establishes an alternate name for the parameter. diff --git a/reference/7.5/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md b/reference/7.5/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md index 0634d8efb397..05e04bc46773 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md +++ b/reference/7.5/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md @@ -1,7 +1,7 @@ --- description: Explains how to add parameters to advanced functions. Locale: en-US -ms.date: 01/04/2025 +ms.date: 01/06/2025 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: about_Functions_Advanced_Parameters @@ -629,6 +629,28 @@ displayed in the `Get-Help -Full` output. This argument has no effect on optional parameters. +#### DontShow argument + +The `DontShow` value is typically used to assist backwards compatibility for a +command where an obsolete parameter cannot be removed. Setting `DontShow` to +`True` hides the parameter from the user for tab expansion and IntelliSense. + +PowerShell v7 (and higher) uses `DontShow` to hide the following obsolete +parameters: + +- The **NoTypeInformation** parameter of `ConvertTo-Csv` and `Export-Csv` +- The **Raw** parameter of `Format-Hex` +- The **UseBasicParsing** parameter of `Invoke-RestMethod` and + `Invoke-WebRequest` + +The `DontShow` argument has the following side effects: + +- Affects all parameter sets for the associated parameter, even if there's a + parameter set in which `DontShow` is unused. +- Hides common parameters from tab completion and IntelliSense. `DontShow` + doesn't hide the optional common parameters: **WhatIf**, **Confirm**, or + **UseTransaction**. + ### Alias attribute The **Alias** attribute establishes an alternate name for the parameter. diff --git a/reference/docs-conceptual/developer/cmdlet/parameter-attribute-declaration.md b/reference/docs-conceptual/developer/cmdlet/parameter-attribute-declaration.md index 1efc377bf368..be9113ee8938 100644 --- a/reference/docs-conceptual/developer/cmdlet/parameter-attribute-declaration.md +++ b/reference/docs-conceptual/developer/cmdlet/parameter-attribute-declaration.md @@ -1,6 +1,6 @@ --- description: Parameter Attribute Declaration -ms.date: 09/13/2016 +ms.date: 01/06/2025 ms.topic: reference title: Parameter Attribute Declaration --- @@ -17,48 +17,69 @@ The Parameter attribute identifies a public property of the cmdlet class as a cm #### Parameters -`Mandatory` ([System.Boolean](/dotnet/api/System.Boolean)) -Optional named parameter. `True` indicates the cmdlet parameter is required. If a required parameter is not provided when the cmdlet is invoked, Windows PowerShell prompts the user for a parameter value. The default is `false`. +`Mandatory` ([System.Boolean][03]) Optional named parameter. `True` indicates the cmdlet parameter +is required. If a required parameter is not provided when the cmdlet is invoked, Windows PowerShell +prompts the user for a parameter value. The default is `false`. -`ParameterSetName` ([System.String](/dotnet/api/System.String)) -Optional named parameter. Specifies the parameter set that this cmdlet parameter belongs to. If no parameter set is specified, the parameter belongs to all parameter sets. +`ParameterSetName` ([System.String][06]) Optional named parameter. Specifies the parameter set that +this cmdlet parameter belongs to. If no parameter set is specified, the parameter belongs to all +parameter sets. -`Position` ([System.Int32](/dotnet/api/System.Int32)) -Optional named parameter. Specifies the position of the parameter within a Windows PowerShell command. +`Position` ([System.Int32][04]) Optional named parameter. Specifies the position of the parameter +within a Windows PowerShell command. -`ValueFromPipeline` ([System.Boolean](/dotnet/api/System.Boolean)) -Optional named parameter. `True` indicates that the cmdlet parameter takes its value from a pipeline object. Specify this keyword if the cmdlet accesses the complete object, not just a property of the object. The default is `false`. +`ValueFromPipeline` ([System.Boolean][03]) Optional named parameter. `True` indicates that the +cmdlet parameter takes its value from a pipeline object. Specify this keyword if the cmdlet accesses +the complete object, not just a property of the object. The default is `false`. -`ValueFromPipelineByPropertyName` ([System.Boolean](/dotnet/api/System.Boolean)) -Optional named parameter. `True` indicates that the cmdlet parameter takes its value from a property of a pipeline object that has either the same name or the same alias as this parameter. For example, if the cmdlet has a `Name` parameter and the pipeline object also has a `Name` property, the value of the `Name` property is assigned to the `Name` parameter of the cmdlet. The default is `false`. +`ValueFromPipelineByPropertyName` ([System.Boolean][03]) Optional named parameter. `True` indicates +that the cmdlet parameter takes its value from a property of a pipeline object that has either the +same name or the same alias as this parameter. For example, if the cmdlet has a `Name` parameter and +the pipeline object also has a `Name` property, the value of the `Name` property is assigned to the +`Name` parameter of the cmdlet. The default is `false`. -`ValueFromRemainingArguments` ([System.Boolean](/dotnet/api/System.Boolean)) -Optional named parameter. `True` indicates that the cmdlet parameter accepts all remaining arguments that are passed to the cmdlet. The default is `false`. +`ValueFromRemainingArguments` ([System.Boolean][03]) Optional named parameter. `True` indicates that +the cmdlet parameter accepts all remaining arguments that are passed to the cmdlet. The default is +`false`. -`HelpMessage` -Optional named parameter. Specifies a short description of the parameter. Windows PowerShell displays this message when a cmdlet is run and a mandatory parameter is not specified. +`HelpMessage` ([System.String][06]) Optional named parameter. Specifies a short description of the +parameter. Windows PowerShell displays this message when a cmdlet is run and a mandatory parameter +is not specified. -`HelpMessageBaseName` -Optional named parameter. Specifies the location where resource identifiers reside. For example, this parameter could specify a resource assembly that contains Help messages that you want to localize. +`HelpMessageBaseName` ([System.String][06]) Optional named parameter. Specifies the location where +resource identifiers reside. For example, this parameter could specify a resource assembly that +contains Help messages that you want to localize. -`HelpMessageResourceId` -Optional named parameter.Specifies the resource identifier for a Help message. +`HelpMessageResourceId` ([System.String][06]) Optional named parameter.Specifies the resource +identifier for a Help message. + +`DontShow` ([System.Boolean][03]) Optional named parameter. `True` indicates that the parameter is +hidden from the user for tab expansion and IntelliSense. The default is `false`. ## Remarks -- For more information about how to declare this attribute, see [How to Declare Cmdlet Parameters](./how-to-declare-cmdlet-parameters.md). +- For more information about how to declare this attribute, see + [How to Declare Cmdlet Parameters][01]. -- A cmdlet can have any number of parameters. However, for a better user experience, limit the number of parameters. +- A cmdlet can have any number of parameters. However, for a better user experience, limit the + number of parameters. -- Parameters must be declared on public non-static fields or properties. Parameters should be declared on properties. The property must have a public set accessor, and if the `ValueFromPipeline` or `ValueFromPipelineByPropertyName` keyword is specified, the property must have a public get accessor. +- Parameters must be declared on public non-static fields or properties. Parameters should be + declared on properties. The property must have a public set accessor, and if the + `ValueFromPipeline` or `ValueFromPipelineByPropertyName` keyword is specified, the property must + have a public get accessor. -- When you specify positional parameters, limit the number of positional parameters in a parameter set to less than five. And, positional parameters do not have to be contiguous. Positions 5, 100, and 250 work the same as positions 0, 1, and 2. +- When you specify positional parameters, limit the number of positional parameters in a parameter + set to less than five. And, positional parameters do not have to be contiguous. Positions 5, 100, + and 250 work the same as positions 0, 1, and 2. - When the `Position` keyword is not specified, the cmdlet parameter must be referenced by its name. - When you use parameter sets, note the following: - - Each parameter set must have at least one unique parameter. Good cmdlet design indicates this unique parameter should also be mandatory if possible. If your cmdlet is designed to be run without parameters, the unique parameter cannot be mandatory. + - Each parameter set must have at least one unique parameter. Good cmdlet design indicates this + unique parameter should also be mandatory if possible. If your cmdlet is designed to be run + without parameters, the unique parameter cannot be mandatory. - No parameter set should contain more than one positional parameter with the same position. @@ -66,14 +87,29 @@ Optional named parameter.Specifies the resource identifier for a Help message. - Multiple parameters can define `ValueFromPipelineByPropertyName = true`. -- For more information about the guidelines for parameter names, see [Cmdlet Parameter Names](standard-cmdlet-parameter-names-and-types.md). +- For more information about the guidelines for parameter names, see [Cmdlet Parameter Names][07]. -- The parameter attribute is defined by the [System.Management.Automation.Parameterattribute](/dotnet/api/System.Management.Automation.ParameterAttribute) class. +- The parameter attribute is defined by the [System.Management.Automation.ParameterAttribute][05] + class. -## See Also +- The `DontShow` parameter has the following side effects: -[System.Management.Automation.Parameterattribute](/dotnet/api/System.Management.Automation.ParameterAttribute) + - Affects all parameter sets for the associated parameter, even if there's a parameter set in + which `DontShow` is unused. + - Hides common parameters from tab completion and IntelliSense. `DontShow` doesn't hide the + optional common parameters: **WhatIf**, **Confirm**, or **UseTransaction**. -[Cmdlet Parameter Names](standard-cmdlet-parameter-names-and-types.md) +## See Also -[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md) +- [System.Management.Automation.Parameterattribute][05] +- [Cmdlet Parameter Names][07] +- [Writing a Windows PowerShell Cmdlet][02] + + +[01]: ./how-to-declare-cmdlet-parameters.md +[02]: ./writing-a-windows-powershell-cmdlet.md +[03]: /dotnet/api/System.Boolean +[04]: /dotnet/api/System.Int32 +[05]: /dotnet/api/System.Management.Automation.ParameterAttribute +[06]: /dotnet/api/System.String +[07]: standard-cmdlet-parameter-names-and-types.md