December 1st, 2014

PowerTip: Avoid Prompt When Using –Debug

Doctor Scripto
Scripter

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'

}

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback