简体   繁体   中英

How can I write a message to the console with PowerShell?

I have tried this:

# Set-ExecutionPolicy Unrestricted
$VerbosePreference = 'Continue'
Write-Verbose "ABC"
$DebugPreference = "Continue"
Write-Debug "Something went wrong."

But both messages come either with the word: VERBOSE or DEBUG before the actual message.

Is there a way I can just display the message content only?

Write-Host is what you would use to write a message to the host. Note that in V4 and below, you can't capture this sort of output to a log file. Starting with V5, you can capture host messages because Write-Host has been updated to use the new Information stream. Likewise in V5, you could just use Write-Information directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM