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
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