Last active
December 13, 2015 19:18
-
-
Save xcud/4961112 to your computer and use it in GitHub Desktop.
Demonstrate built-in Verbose support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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