Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Cannot redirect Powershell output using Task Scheduler

$
0
0

I'm running Windows Server 2008 Enterprise x64 R2.

Sample script x.ps1:

(Get-Date).DateTime
Write-Output "output"
Write-Warning "warning"
Write-Error "error"

Run this in the cmd console:

powershell -command ".\x.ps1" *> x.log.  Works like a charm, I've got a log.

Now delete x.log.  Create a scheduled task with the exact same command:  powershell -command ".\x.ps1" *> x.log.  Run the scheduled task.  No log.

WTF?  How hard should this be?  I've spent hours Googling, I know this problem comes up a lot.  Why is a scheduled task so different than running from a cmd console?

I also tried powershell -file, as well as Start-Transcript, which looked promising, but I don't like the line wrapping in the scheduled task output.


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>