Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Created January 12, 2021 07:08
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 gsscoder/1b20227c5d6a8c176d89e4ee833022f0 to your computer and use it in GitHub Desktop.
Save gsscoder/1b20227c5d6a8c176d89e4ee833022f0 to your computer and use it in GitHub Desktop.
PowerShell code to test if -Verbose switch is enabled
[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