Re directions in power shell RRS feed

  • Question

  • Hi All,

    I have the three lines below in my script.  I tried to redirect the success to a file and then error to another log file using the command line argument below.

    While running the the script the contents of the log files doesnt look correct.  Please let me know what I am doing wrong.

    Write-Host "f=$file,p=$fname,h=$System,a=$values,s=$sha1,s2=$sha2,v=$ver,Live=$live" Write-Error "f=$file,p=$fname,h=$System,a=$values,s=$sha1,s2=$sha2,v=$ver,Live=$live"

    Write-Output "f=$file,p=$fname,h=$System,a=$values,s=$sha1,s2=$sha2,v=$ver,Live=$live"

     ./audit_v1.ps1 >audit.out 2>error.log

    • Moved by Bill_Stewart Wednesday, September 4, 2019 7:37 PM Abandoned
    Wednesday, March 27, 2019 8:09 PM

All replies

  • Write-Host cannot be redirected and Write error outputs on channel 2.


    Wednesday, March 27, 2019 10:48 PM