Write-Debug

Write a debug message to the host display.

Syntax
      Write-Debug [-message] string [CommonParameters]

Key
   -message string
       The debug message to send to the console.
       {may be piped}

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

By default, debug messages are not displayed in the console, but you can display them by using the Debug parameter or the $DebugPreference variable.

The action of Write-Debug is dependent on the value of $DebugPreference
If $DebugPreference = "Continue" PowerShell will show the debug message.
If $DebugPreference = "SilentlyContinue" PowerShell will not show the message.
If $DebugPreference = "Stop" PowerShell will show the message and then halt.
If $DebugPreference = "Inquire" PowerShell will prompt the user.

Example

Write a debug message:

PS C:\> $DebugPreference = "Continue"
PS C:\> Write-Debug "Something went wrong."


#I hope that someone gets my, I hope that someone gets my, Message in a bottle# ~ Sting & The Police

Related PowerShell Cmdlets:

Write-Error - Write an object to the error pipeline.
Write-Host - Display objects through the host user interface.
Write-Output - Write an object to the pipeline.
Write-Progress - Display a progress bar.
Write-Verbose - Write a string to the host’s verbose display.
Write-Warning - Write a warning message.


 
Copyright © SS64.com 1999-2019
Some rights reserved