Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.