Bearbeiten

Freigeben über


Cmdlet Attributes

Windows PowerShell defines several attributes that you can use to add common functionality to your cmdlets without implementing that functionality within your own code. This includes the Cmdlet attribute that identifies a Microsoft .NET Framework class as a cmdlet class, the OutputType attribute that specifies the .NET Framework types returned by the cmdlet, the Parameter attribute that identifies public properties as cmdlet parameters, and more.

In This Section

Attributes in Cmdlet Code Describes the benefit of using attributes in cmdlet code.

Attribute Types Describes the different attributes that can decorate a cmdlet class.

Alias Attribute Declaration Describes how to define aliases for a cmdlet parameter name.

Cmdlet Attribute Declaration Describes how to define a .NET Framework class as a cmdlet.

Credential Attribute Declaration Describes how to add support for converting string input into a System.Management.Automation.PSCredential object.

OutputType attribute Declaration Describes how to specify the .NET Framework types returned by the cmdlet.

Parameter Attribute Declaration Describes how to define the parameters of a cmdlet.

ValidateCount Attribute Declaration Describes how to define how many arguments are allowed for a parameter.

ValidateLength Attribute Declaration Describes how to define the length (in characters) of a parameter argument.

ValidatePattern Attribute Declaration Describes how to define the valid patterns for a parameter argument.

ValidateRange Attribute Declaration Describes how to define the valid range for a parameter argument.

ValidateScript Attribute Declaration Describes how to define the possible values for a parameter argument.

ValidateSet Attribute Declaration Describes how to define the possible values for a parameter argument.

Reference

Writing a Windows PowerShell Cmdlet