Save Powershell-console output to text file

Save Powershell-console output to text file

Sometime it's very difficult to find error in Powershell script, especially if script is running in some dedicated session, for example, under SYSTEM account. There will be errors but you'll never know about them.

That's why I started to search a way to log output from Powershell-console to file. Here is the solution.

$(
   <some commands>
) *>&1 > "C:\out.log"

For example:

$(
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
) *>&1 > "C:\out.log"

Of course, you can place as many command as you want between brackets.

powershell (en)

  • Hits: 15134
Add comment

Comments  
RE: Save Powershell-console output to text file
Amazing Thanks1

Related Articles