Skip to content

Wrong description #4093

@bjoernf73

Description

@bjoernf73

The documentation states:

"The third command writes a debug message. It uses the Debug common parameter to override the value of $DebugPreference and to display the debug messages resulting from this command.
As a result, even though the value of $DebugPreference is SilentlyContinue, the debug message appears.".

This is a bit misleading. The debug switch actually changes the $DebugPreference within the context of that command. Also to be seen in the following example:

function testf {
[cmdletbinding()]
param()
Write-Host "DebugPreference is $DebugPreference"
}

PS C:> testf
DebugPreference is SilentlyContinue
PS C:> testf -debug
DebugPreference is Inquire
PS C:>

Moreover, as seen in the above example, the -debug switch doesn't just "display" the message as is stated in the helptext - it sets $DebugPreference to "Inquire" (for some reason totally different from the verbose switch, which would set it to "continue"), and halts execution to inquire if execution should continue - which is very different when used in scripts, for example.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

area-debuggingArea - Debugging servicesarea-utilityArea - Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions