Homegrown common parameters
Also in the time of PowerShell Version 1.0, the only way to get native support for common parameters (for example, –Verbose and –ErrorAction) was to write a cmdlet using managed code. Since scripters, in general, are not C# or VB.NET programmers, there was a tendency at that time to manually implement the common parameters. For instance, it wasn't uncommon to find code like this:
function Get-Stuff{
Param($stuffID,[switch]$help)
if($help){
write-host "Usage: get-stuff [-stuffID] ID"
write-host "Retrieves a list of stuff which matches"
write-host "the given stuffID"
return
}
#get the stuff
}This was not an unapproved method in fact. Here is a blog post from Jeffery Snover advocating implementing the –whatif, –Confirm, and –Verbose parameters in script:
The post even contains a note explaining how important this method...