Welcome › Forums › General PowerShell Q&A › cmdlets vs functions
- This topic has 2 replies, 3 voices, and was last updated 5 years, 6 months ago by
Keymaster.
-
AuthorPosts
-
-
May 30, 2014 at 3:15 am #15761
Hi, I am learning PowerShell by using CBT PowerShell Ultimate Training by Don Jones. After covering first 62 lessons (nuggets) everything so far is pretty clear because Don explained in details all covered areas. One thing comes to my mind and that is the difference between cmdlet and function. Don covered basic and advanced functions that can accept input from pipeline and by passing parameter names without pipeline, which is also the case for cmdlets written by Microsoft. Is writing cmdlets obsolete, are functions the best way to write custom code and then putting them into the custom module? If not how to write custom cmdlet with the same level of functionality like advanced functions?
-
May 30, 2014 at 3:53 am #15763
Here's a link to an overview of writing a Powershell cmdlet:
http://msdn.microsoft.com/en-us/library/dd878294%28v=vs.85%29.aspxBasically a true Powershell cmdlet is written in a .NET programming language, typically C#, and compiled – so in a way it's a real application. An advanced function is written in Powershell (although you could include some custom C# code) and is not compiled. There are probably performance benefits to implementing a compiled cmdlet rather than an advanced function but the functions exist for us average joe admins who aren't real programmers to be able to develop and share our own tools.
This is probably not the most eloquent description so I'll leave the nitty-gritty details to those who know more about the developer side of Powershell and .NET.
-
May 30, 2014 at 5:21 am #15765
That's about right. A cmdlet actually sets the baseline; it can do "everything." Until we got advanced functions, script was more limited.
-
-
AuthorPosts
- The topic ‘cmdlets vs functions’ is closed to new replies.