System.Management.Automatio ...


ParameterAttribute Class
Defines the Parameter attribute that is used to identify a cmdlet or function parameter. For more information about the syntax and parameters used to declare the Parameter attribute for cmdlets, see >ParameterAttribute Declaration.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in system.management.automation.dll)
Usage

Dim instance As ParameterAttribute
Syntax

Visual Basic
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=True)> _
Public NotInheritable Class ParameterAttribute
    Inherits ParsingBaseAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=true)] 
public sealed class ParameterAttribute : ParsingBaseAttribute
C++
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field, AllowMultiple=true)] 
public ref class ParameterAttribute sealed : public ParsingBaseAttribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=true) */ 
public final class ParameterAttribute extends ParsingBaseAttribute
JScript
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=true) 
public final class ParameterAttribute extends ParsingBaseAttribute
Example

This example shows how the Parameter attribute is used to declare a mandatory parameter.

C#
[Parameter(Position = 0, Mandatory = true)]
public string UserName
{
  get { return userName; }
  set { userName = value; }
}
private string userName;
Remarks

For more information about the syntax and parameters used to declare the Parameter attribute for functions, see about_Functions_Advanced_Parameters in the Microsoft TechNet library..

Do not declare parameters that have the following parameter names. Windows PowerShell adds these parameters to cmdlets in order to provide a consistent user experience across all cmdlets.

  • Debug

  • ErrorAction

  • ErrorVariable

  • OutBuffer

  • OutVariable

  • Verbose

  • WarningAction

  • WarningVariable

  • Confirm

  • WhatIf

  • UseTransaction

For more information about about parameter names, see >Cmdlet Parameter Names.


Inheritance Hierarchy

System.Object
   System.Attribute
     System.Management.Automation.Internal.CmdletMetadataAttribute
       System.Management.Automation.Internal.ParsingBaseAttribute
        System.Management.Automation.ParameterAttribute
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, Windows 7, Windows 2008 R2

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP, Windows 7, Windows 2008 R2
See Also

Page view tracker