Created
June 30, 2019 22:33
-
-
Save goyalmohit/3f359acc75a4ea40a466afac3b17abc2 to your computer and use it in GitHub Desktop.
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
Write-Output 'Understand how $PreferenceVariable controls verbose output' | |
# prints current value of $verbosepreference | |
Write-Host "VerbosePreference is set to: $VerbosePreference" | |
# understanding how $VerbosePreference controls the verbose output | |
# case 1: set to bypass verbose stream | |
$VerbosePreference = "SilentlyContinue" | |
Write-Host "VerbosePreference is set to: $VerbosePreference" | |
Write-Verbose -message "This line will not be shown" | |
Write-Verbose -message "This line will be shown" -Verbose | |
# case 2: set to output verbose stream | |
$VerbosePreference = "Continue" | |
Write-Host "VerbosePreference is set to: $VerbosePreference" | |
Write-Verbose -message "This line will be shown" | |
Write-Verbose -message "This line will not be shown" -Verbose:$false | |
# remember to set the default value again | |
$VerbosePreference = "SilentlyContinue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment