Powershell and Taskscheduler

Hello

We are using Sharepoint 2013 and Windows 2008R2. When running a powershell script from a batch direct from the command line the output is redirected to a file.

If this is done through the task scheduler the output is not redirected to the file.

The logfile is programmed within the powershell script as function

Function LogWrite
{
  Param ([string]$logstring) 
  Add-content $Logfile -value $logstring -Verbose -
}

Do you have any idea

Cheers

Nickxx

April 10th, 2013 10:40am

Does the "Run As account" of the task have permissions to write to the file?
Free Windows Admin Tool Kit Click here and download it now
April 12th, 2013 5:24am

Can you compare value of $Logfile by running it from batch direct and when running with Task scheduler. Also, is there any parameter passed from batch script into the powershell script, that maybe missed when creating the Task.
March 10th, 2014 9:19am

Hi Guru
Thank you for your reply
Regards
Juan

Free Windows Admin Tool Kit Click here and download it now
March 11th, 2014 1:22pm

Hi Prasanna
Thanks for the reply I will try it.
Regards
Juan

March 11th, 2014 1:22pm

Try after removing -Verbose

-Verbose must be expecting a user interaction. So Remove it and try :)

Free Windows Admin Tool Kit Click here and download it now
April 15th, 2015 3:25am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics