Bearbeiten

Freigeben über


Attributes in Cmdlet Code

To use the common functionality provided by Windows PowerShell, the classes and public properties defined in the cmdlet code are decorated with attributes. For example, the following class definition uses the Cmdlet attribute to identify the Microsoft .NET Framework class in which the Get-Proc cmdlet is implemented. (This cmdlet is used as an example in this document, and is similar to the Get-Process cmdlet provided by Windows PowerShell.)

[Cmdlet(VerbsCommon.Get, "Proc")]
public class GetProcCommand : Cmdlet

These attributes are considered metadata because their implementation is separate from the implementation of the cmdlet code. When the Windows PowerShell runtime runs the cmdlet, it recognizes the attributes and then performs the appropriate action for each attribute.

Although you might want to implement your own version of the functionality provided by these attributes, a good cmdlet design uses these common functionalities.

For more information about the different attributes that can be declared in your cmdlets, see Attribute Types.

See Also

Attribute Types

Writing a Windows PowerShell Cmdlet