Powershell Echo Statement + Variable In One line
In powershell, you can use Write-Host as follows:
$filename = "foo.csv"
Write-Host 'The file' $filename 'has been processed.'
-> The file foo.csv has been processed.
If you use double quotes you can reference the variable directly in the string as they allow variable expansion, while single quotes do not allow this.
$filename = "foo.csv"
Write-Output "The file $filename has been processed."
-> The file foo.csv has been processed.
Also, echo
is actually just an alias for Write-Output
, so I've used the full name.