Thursday, August 31, 2017

Powershell Redirection of output

Was needing to send error output from a command to the logfile.
Ran across these two articles that helped me.


Powershell Move-Item logging
You may just need to collapse the output file descriptors. According to the about_Redirection page, it should work if you do the following:
Move-Item c:\temp\*.* C:\Temp\2014 -Verbose -Force *>&1 | 
    Out-File -FilePath $MyLogPath
Or if you want to see the output at the same time
Move-Item c:\temp\*.* C:\Temp\2014 -Verbose -Force *>&1 |
    Tee-File -FilePath $MyLogPath





No comments:

Post a Comment