I found that the TaskEventLog does not recognize credentials that have already been provided to an instance of TaskService. In order for me to get the TaskEventLog to work I needed to pass the credentials in the constructor and also prefix the task path with a backslash.
using (TaskService ts = new TaskService(machine, user, domain, password))
{
TaskFolder folder = ts.GetFolder("MyFolder");
foreach(Task t in folder.GetTasks())
{
Console.WriteLine(String.Format("{0} ({1})", t.Name, t.State.ToString()));
TaskEventLog log = new TaskEventLog(machine, "\\" + t.Path, domain, user, password);
Console.WriteLine(String.Format("Log size {0}", log.Count));
}
}
↧