What is a PowerShell cmdlet?

自古美人都是妖i 提交于 2019-12-03 17:20:37

问题


Approaching cmdlets in a conceptual way,

  1. How are they made? Are they compiled?

  2. Is it the equivalent of a batch file for PowerShell? Is it a script or a binary?

  3. What is the structure used for storing these cmdlets?


回答1:


A PowerShell cmdlet is a compiled piece of .NET code, more precisely a single class if I am not mistaken. Cmdlets are kind of the "native" commands in PowerShell land, being able to handle object input and output as well as usually playing nice and well with the (object-based) pipeline.

Cmdlets have no direct representation in the file system, as they are not programs or similar. They exist solely within PowerShell. You can use the Get-Command cmdlet to query all available cmdlets, functions, etc.

You can write cmdlets with a .NET language, such as C#. With PowerShell v2 there is also the possibility to write so-called advanced functions which behave similarly to cmdlets and have comparable capabilities but are interpreted PowerShell code, instead of compiled classes. This may incur a run-time overhead.




回答2:


This link may help in understanding powershell cmdlet:

http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-cmdlet/




回答3:


See Scripting with Windows PowerShell.




回答4:


A PowerShell cmdlet is a user-created extension to the PowerShell scripting language. The Cmdlet itself is a .NET class extending from PSCmdlet. Usually, additional components are included with the cmdlet to provide help and registering the cmdlet.

A cmdlet allows you to access to all functions accessible through the .NET virtual machine. This can range from simple script aids to fully functional programs.



来源:https://stackoverflow.com/questions/1111654/what-is-a-powershell-cmdlet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!