I am working with a 3rd party cmdlet that I am calling in a script. Somehow, no matter what I set $DebugPreference to, if I call the cmdlet with -Debug, it always prompts to continue. I’ve tried:
$DebugPreference = ‘Continue’
$script:DebugPreference = ‘Continue’
$Global:DebugPreference = ‘Continue’
What am I missing?
TIA,
-Peter
What is that cmdlet ? can you share the source ?
In PowerShell v5.1, calling a cmdlet with the -Debug
parameter always sets $DebugPreference
to Inquire
for the duration of the cmdlet. In other words, you should set the variable and then call the cmdlet without the -Debug
parameter.
In PowerShell 6.2 and newer, this behaviour was altered and the -Debug
parameter itself actually sets $DebugPreference
to Continue
instead.