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?
Here’s a link to an overview of writing a Powershell cmdlet:
Basically 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.
That’s about right. A cmdlet actually sets the baseline; it can do “everything.” Until we got advanced functions, script was more limited.