Whilst creating a script I wanted to be able to trace what was happening as the script ran. In my VBScript days I would have set up a flag to determine if I needed verbose output and then tested for it. Even with cut and paste this can be laborious. In PowerShell we have Write-Verbose, but how do we turn it on? The -Verbose parameter is one of the PowerShell ‘Common Parameters’. To enable these we need a [CmdletBinding()] line as the first executable line in our script.
Have a look at PowerShell – Using Common Parameters for a great overview.