I have a powershell script that works great from cmd line, but flakes out a lot when running from task scheduler.

So I need to see all the console output from all the commands.

The script does a lot of external commands (net use, robocopy, etc). The output from these commands is what I most need.

We do not want to instrument each command, because it is ugly, and because we need to run it interactively (and see what is going on).

I tried the powershell "Start-Transcript" with -Verbose, but NONE of the commands are logged to the transcript file. Even when we followed this directive by a guy on the powershell team: | Out-Default (e.g. ipconfig.exe | Out-Default), we STILL do not see the output in the transcript.

What next?

2 Answers 2


Configure the logging to occur within the scheduled task via redirection of the powershell invocation:

cmd /c powershell.exe -noninteractive -file c:\temp\script.ps1 > c:\temp\some.log 2>&1

If the ROBOCOPY log is doing more than 10 files, I would keep that separate with the /LOG:c:\temp\robo.log option that command supports.

  • Hmmmm From a cmd line , that works great. From a scheduled task, "c:\temp\some.log" is not created. Maybe the params need quoting in a scheduled task? Mar 29, 2016 at 3:43
  • Oops... see edit. Got to work if I wrapped ps invoke with cmd. lol
    – Clayton
    Mar 29, 2016 at 16:34

Well, even if not the prettiest of solutions you could perhaps do something like the following?

net use z: \\my\path >> mylogfile.txt 2>&1

And you could do the same with the logging abilities of robocopy, just append to the same file.

  • No sale, sorry. OP enhanced. Mar 24, 2016 at 19:20
  • Well, if PS 3.0 or higher you could try robocopy.exe <more stuff> | Tee-Object -FilePath Mylog.txt -Append or such...
    – notjustme
    Mar 24, 2016 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .