Write-Verbose

Writes text to the verbose message stream.

语法

Default (默认值)

Write-Verbose
    [-Message] <String>
    [<CommonParameters>]

说明

The Write-Verbose cmdlet writes text to the verbose message stream in Windows PowerShell. Typically, the verbose message stream is used to deliver information about command processing that is used for debugging a command.

By default, the verbose message stream is not displayed, but you can display it by changing the value of the $VerbosePreference variable or using the Verbose common parameter in any command.

示例

Example 1: Write a status message

PS C:\> Write-Verbose -Message "Searching the Application Event Log."
PS C:\> Write-Verbose -Message "Searching the Application Event Log." -Verbose

These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.

The second command uses the Verbose common parameter, which displays any verbose messages, regardless of the value of the $VerbosePreference variable.

Example 2: Set $VerbosePreference and write a status message

PS C:\> $VerbosePreference = "Continue"
PS C:\> Write-Verbose "Copying file $filename"

These commands use the Write-Verbose cmdlet to display a status message. By default, the message is not displayed.

The first command assigns a value of Continue to the $VerbosePreference preference variable. The default value, SilentlyContinue, suppresses verbose messages. The second command writes a verbose message.

参数

-Message

Specifies the message to display. This parameter is required. You can also pipe a message string to Write-Verbose.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False
别名:Msg

参数集

(All)
Position:0
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

String

You can pipe a string that contains the message to Write-Verbose.

输出

None

Write-Verbose writes only to the verbose message stream.

备注

  • Verbose messages are returned only when the command uses the Verbose common parameter. For more information, see about_CommonParameters.
  • In Windows PowerShell background jobs and remote commands, the $VerbosePreference variable in the job session and remote session determine whether the verbose message is displayed by default. For more information about the $VerbosePreference variable, see about_Preference_Variables.