0

Having a string on its own in Powershell outputs it to the console. At first glance it looks like i behaves as Write-Host. Does it?

function AnyFunction(){
    'aaa'
    Write-Host 'bbb'
}
LosManos
  • 7,195
  • 6
  • 56
  • 107
  • 1
    `'aaa'` is the same as `write-output 'aaa'`. Avoid `write-host` / use instead `write-output` or `write-information`; the latter outputs depending on the `$informationPreference` property. – JohnLBevan May 03 '18 at 07:23
  • 2
    Check [this](https://stackoverflow.com/questions/10832000/best-way-to-write-to-the-console-in-powershell) out! – Vivek Kumar Singh May 03 '18 at 07:23
  • Worth noting that `Write-Information` was introduced with PowerShell v5 and is not available in earlier versions. `Write-Host` writes output directly to the host console (thus bypassing pipelines, etc.) and should *only* be used for displaying information to a user. – Ansgar Wiechers May 03 '18 at 08:25

0 Answers0