I am using Powershell 2009 on a WIN-Server 2008 R2
I have seen several suggestions on how to "redirect" the output generated by a 'cmd.exe /c', but none of the suggested solutions were successful.
I have a simple cmd
cmd.exe /c my_program.cmd $file.basename
This process creates a lot of screen output and this command is in a loop of all files in a directory.
I want to capture the output to a file "$lgfile"
I have used
I would be grateful for any suggestions
Use Start-Process with the RedirectStandardOutput switch, for example:
$MyOutputFile = C:\MyOutputFile.txt Start-Process -FilePath c:\windows\system32\cmd.exe -ArgumentList '/c C:\YourCommand.bat' -Wait -NoNewWindow -RedirectStandardOutput $MyOutputFile
You must be logged in to reply to this topic.