1

I'm running a batch file from Task Scheduler which I execute a PowerShell Scripts. So, I have a batch file (TestFD.bat):

Powershell -Command "& {C:\Users\csadouni\Desktop\testFDCOMM.ps1}" > logFDCOM.txt 

My script PowerShell does migration of my documents on my SharePoint Online site and it's work well (the log file is generated perfectly) if I call the batch file from cmd.exe. Then From the task Windows it work well but the issue seem on task windows doesn't recognize my output file redirection. So no file generated

I tried all these solutions, but no one resolve my issue.

How can I redirect PowerShell output when run from Task Scheduler?

Executing PowerShell from Windows Task Scheduler

How do I execute a PowerShell script automatically using Windows task scheduler?

I wouldn't running only my PSscript directly from Scheduler Task, because I need my output redirection of my Sharegate transfer (Sharegate is a product to automate task, manage, administer and migrate site, content on SharePoint & Office 365), So, I need my output of PowerShell migration after I have many other scripts to schedule them on my batch file. What am I missing?

Any help is appreciated thanks!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Charaf
  • 11
  • 2
  • 3
    Given that it's unclear to me exactly what context this will be run in, what happens if you give an absolute path for the redirect target? –  Nov 10 '17 at 18:39
  • Within batch file , i can excecute my powershell command and the log file is generated. But , in task Scheduler , the task is done (script did the migration) but non file generated. Also , if i give a absolute path the issue still the same. tnx – Charaf Nov 10 '17 at 18:45
  • You should update the question with these details. Comments can be deleted. –  Nov 10 '17 at 18:56

1 Answers1

0

You could log the PowerShell output to file in the PowerShell script instead of logging the batch output when calling the script.

Marmalade
  • 94
  • 8