Skip to content

Instantly share code, notes, and snippets.

@xcud
Last active December 13, 2015 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcud/4961112 to your computer and use it in GitHub Desktop.
Save xcud/4961112 to your computer and use it in GitHub Desktop.
Demonstrate built-in Verbose support
<#
.Synopsis
Demonstrate built-in Verbose support
.Example
PS> Correct-Example -Verbose
VERBOSE: This works
PS> Incorrect-Example -Verbose
PS> Incorrect-Example2 -Verbose
VERBOSE: This works but don't do it. Let CmdletBinding do the work.
#>
function Correct-Example {
[CmdletBinding()]
param()
Write-Verbose "This works"
}
function Incorrect-Example {
Write-Verbose "This doesn't work."
}
function Incorrect-Example2 {
param([Switch]$Verbose)
if($Verbose.IsPresent) { $VerbosePreference = 'Continue' }
Write-Verbose "This works but don't do it. Let CmdletBinding do the work."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment