Powershell Output String

There are several ways:

Write-Host: Write directly to the console, not included in function/cmdlet output. Allows foreground and background colour to be set.

Write-Debug: Write directly to the console, if $DebugPreference set to Continue or Stop.

Write-Verbose: Write directly to the console, if $VerbosePreference set to Continue or Stop.

The latter is intended for extra optional information, Write-Debug for debugging (so would seem to fit in this case).

Powershell has an alias mapping for command echo to Write-Output, so:

Example

Example


$txtfilepath= "c:\test\test.txt"
$txtfilepathSize = (Get-Item $txtfilepath).length;
echo "txtfilepathSize : $txtfilepathSize"

Copy and Try it