Created
January 12, 2021 07:08
-
-
Save gsscoder/1b20227c5d6a8c176d89e4ee833022f0 to your computer and use it in GitHub Desktop.
PowerShell code to test if -Verbose switch is enabled
This file contains 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
[CmdletBinding()] | |
param () | |
Set-StrictMode -Version Latest | |
$verbose = if ($PSBoundParameters.ContainsKey('Verbose')) { | |
$PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent } else { $false } | |
"Verbose enabled: $verbose" | Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment