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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈