Write-Debug

 

SYNOPSIS

Writes a debug message to the host display.

 

SYNTAX

Write-Debug [-message] <string> [<CommonParameters>]

 

DETAILED DESCRIPTION

Writes debug messages to the console from a script or command. Whether the message is displayed in the console depends upon the value of the $DebugPreference variable. Type $DebugPreference to see its current value. To set the variable for the session, type $DebugPreference  ="<value>". The valid values are: SilentlyContinue, Stop, Continue and Inquire. If the value is SilentlyContinue, Write-Debug does not display a message to the console.

 

PARAMETERS

 

-message <string>

Specifies the debug message to send to the console.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

true (ByValue)

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

String

 

RETURN TYPE

None

 

NOTES

 

For more information, type "Get-Help Write-Debug -detailed". For technical information, type "Get-Help Write-Debug -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

EXAMPLE 1

 

$DebugPreference = "Continue"

Write-Debug "This script has attempted to open file xyx and cannot."

$DebugPreference = "SilentlyContinue"

Write-Debug "This is another debug statement."

 

This command writes a debug message which will be shown or not depending upon the value of $DebugPreference. The value "SilentlyContinue" means do not show the statement.  The Value "Continue" means show the value.

 

DEBUG: This script has attempted to open file xyx and cannot.

 

RELATED LINKS

Write-Verbose

Write-Error

Write-Host

Write-Progress

Write-Output

Write-Warning