Is it possible to check if -Verbose argument was given in Powershell? -


i have written own powershell logging function log parameters stream (on stream write message) , message (the message write).

the idea can write outputs both console , log-file. in function determine on stream publish message (with switch statement) , write message stream , log-file:

switch ($stream) {     verbose {         write-output "$logdate [verbose] $message" | out-file -filepath $sglogfilename -append         write-verbose $message         break     } } 

the question now, possible check if -verbose argument given?

the goal write message log-file if -verbose given.

i looked in following docs didn't find helpful:
- about_parameters
- about_commonparameters

also, -whatif parameter not work write-verbose.

thanks lot answers!

inside script check this:

$pscmdlet.myinvocation.boundparameters["verbose"].ispresent 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -