A couple of days ago I posted a blog article titled "PowerShell function: Test-ConsoleColor provides a visual demonstration of the foreach scripting construct" and today I thought I would walk you through that function step by step since it's what I consider to be a well written PowerShell function.
It starts out by using the #Requires statement to require at least PowerShell version 3 or it won't run. It also requires that the PowerShell Community Extensions module be installed since it uses a function from that module and continuing without it only leads to errors:
#Requires -Version 3.0 -Modules Pscx
The function is then declared using a Pascal case name that uses an approved verb along with a singular noun. Comment based help is provided just inside the function declaration. This isn't the only location where comment based help can be specified at, but it's my preferred location for it.
Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.
µRecommend0 recommendationsPublished in