I need to execute some periodic console applications that give me some results (on the console)… How can I execute it and have its return data sent to my email?
I tried to use [Diagnostics.Process]::Start() and it launches my application but i don’t know how to get the return… I do not want the exitCode, I want the text that the application prints on screen.
Using PS V2 CTP3.
*** UPDATE
The solutions presented worked fine but i have a problem… this application that i need to execute is gfix from the firebird database and now i discovered a thing, I can’t redirect the output of gfix to a file, if i execute on command prompt the line:
gfix.exe -v -f dabatase.gdb > c:\test.txt
it print the output on the screen and the file is empty.
Same thing if I try to assign it to a variable… I don’t know what difference gfix has from the other console apps that I use, but looks like its output can’t be redirected.
Has someone seeing this?
*** UPDATE 2
Even if I use Start-transcript /Stop-Transcript, although on the screen I see the gfix output, on the file there is only the commands :/
*** UPDATE 3
Found the solution here
http://edn.embarcadero.com/br/article/25605
Something like this could work:
I think in this case
[Diagnostics.Process]::Start()is not needed. Besides that there is a cmdletStart-Processthat does almost the same.