PowerShell script exchange
Post Reply
benjos
Novice
Posts: 3
Liked: never
Joined: Apr 23, 2014 8:39 pm
Full Name: Benjamin Perez
Contact:

View console output from powershell

Post by benjos »

I have set up a script to run after a back up is done on the "Post Job Activity" the command calls for c:\users\ben\desktop\test.cmd the cmd file has the command

Code: Select all

start powershell.exe c:\users\ben\desktop\test1.ps1
the powershell script is executed correctly but the console does not open so I can see the output from the script. Is there a way to call the script from veeam and be able to see the console so I can see the write-host output of the powershell script?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: View console output from powershell

Post by veremin »

You mean you want to see the PS pipeline and what is output to it during script execution? Thanks.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: View console output from powershell

Post by tdewin »

You could create a logfile in your script and then pipeline your commands to outfile

Code: Select all

$logfile = ("{0}\logfile{1}.txt" -f "c:\d",(Get-Date -format "yyyyMMddhhmmss"))

"hello" | Out-File -Append $logfile
get-process | Out-File -Append $logfile
benjos
Novice
Posts: 3
Liked: never
Joined: Apr 23, 2014 8:39 pm
Full Name: Benjamin Perez
Contact:

Re: View console output from powershell

Post by benjos »

v.Eremin wrote:You mean you want to see the PS pipeline and what is output to it during script execution? Thanks.
Correct, I would like to see the output during script execution. The scrip copies my backups to an external drive and while it is executing I have not idea of how far in the process the script is. So how do I see output during script execution?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: View console output from powershell

Post by veremin »

Can you try to run this very command from the command line ("Run")? Will you see corresponding PS window or not? Does adding -noexit parameter make any difference (start powershell.exe -noexit)? Thanks.
benjos
Novice
Posts: 3
Liked: never
Joined: Apr 23, 2014 8:39 pm
Full Name: Benjamin Perez
Contact:

Re: View console output from powershell

Post by benjos »

I have tried to use (start powershell.exe -noexit) but I still don't see the output. I can tell the script is running because under task manager I see the process but I don't see a window with output. If I double click the cmd file that calls (start powershell.exe) I see the window but not when called by Veeam from the Post Job Activity.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: View console output from powershell

Post by veremin »

May be there is some account issue, since post job activity is executed under veeam service account? Thanks.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: View console output from powershell

Post by tdewin »

Checked it with Process Explorer. Powershell is executed as service account as expected and it is not possible to bring the window to the front. Again I would advise you to write to a log file in your script.

Then from another window you can monitor the process with the tail and wait option in powershell v3
Get-Content -Tail 10 -wait E:\logs\jobjob.log
Apparently (if you are not using v3), you can find a similar command in the ps community extensions:
Get-FileTail
http://pscx.codeplex.com/
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests