I want to collect all output from my script in a log file and must use write-output instaed of write-host.
Write-Output \"Server:\" $a looks like
Write-Output "Server: $a"
Write-Output ("Server: {0}" -f $a)
Write-Output ("Server: " + $a)
If you want to collect the output from a script into a log file, consider using Start-Transcript. It logs every command and all PowerShell output to a file. It doesn't log anything sent to stdout, however, so if you're using any legacy commands, you'll have to pipe their output to Write-Host:
Start-Transcript C:\logs\mylog.txt
Write-Host "Server: " $a
ping | Write-Host