Samantha J T Star
Samantha J T Star

Reputation: 32758

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?

Upvotes: 0

Views: 220

Answers (1)

Keith Hill
Keith Hill

Reputation: 201592

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.

Upvotes: 1

Related Questions