PowerTip: Avoid Prompt When Using –Debug

Doctor Scripto

Summary: Boe Prox shows how to avoid being prompted when using –Debug.

Hey, Scripting Guy! Question I love using –Debug in functions to figure out what is going on, but how can I avoid being prompted
           each time I run into Write-Debug in my code?

Hey, Scripting Guy! Answer After you declare your parameters, check for –Debug, and set the $DebugPreference 
           value to ‘Continue’ instead of ‘Inquire’:

If ($PSBoundParameters[‘Debug’]) {

    $DebugPreference='Continue'

}

0 comments

Discussion is closed.

Feedback usabilla icon