Write-Host => Export to a file
powershell, powershell-1.0, powershell-2.0
Solution
`Write-Host` redirects the output only to the console.
You can use `Write-Output` and redirect to a file (`> export.txt` or pipe to `Out-File export.txt`)
In the extreme case when you absolutely need to redirect all output from a script, take a look to this cmdlet:
Start-Transcript
Get-Help Start-Transcript -full
Problem
I have got a script with some commands such as `Write-Host "Server1"`. How can I export it to a file? When I tried with `script > export.txt` it didn't work.