Summary: Boe Prox shows how to avoid being prompted when using –Debug.
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?
After you declare your parameters, check for –Debug, and set the $DebugPreference
value to ‘Continue’ instead of ‘Inquire’:
If ($PSBoundParameters[‘Debug’]) {
$DebugPreference='Continue'
}