14

I have selected the Enable All Tasks History option in the Task Scheduler Library of Windows Server 2008 R2.

For most tasks, I’d like to have the history kept but I’m wondering if it’s possible to disable the history for some tasks (non-critical and frequent) and not others?

Synetech
  • 908
  • 1
  • 12
  • 27
Mouffette
  • 495
  • 7
  • 11
  • 1
    Or conversely, keep it disabled for all tasks and only enable it for some. – Synetech Aug 21 '12 at 15:06
  • 3
    I don't think it is possible however.; It looks like you can use a bug to get this functionality. Add an ampersand to the task name and I believe it will not show up in history. [See here.][1] [1]: http://stackoverflow.com/a/33786418/2184401 – Brett Larson Nov 08 '16 at 05:57
  • Hello, since you posted the question did you find any way to disable logging for one/enable only it for a few ? I was wondering exactly the same thing for logging purpose, because I have a task running every two minutes which I would like to avoid to view in event log. Thank you ! – AFract Aug 29 '17 at 10:15

1 Answers1

1

It doesn't look like there's a good way filter this like you are thinking of, but you could add a couple actions to your task to disable logging first, enable it after.

There is a chance that there is another scheduled task trying to write to the log at that time, so you would need to be okay with some potential logging loss on that end.

See below script from here

$logName = 'Microsoft-Windows-TaskScheduler/Operational'

$log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration

$logName

$log.IsEnabled=$true

$log.SaveChanges()

The only other way I can think of doing this is disabling it across the board and then for the events you want logging you could log manually by encapsulating your actual commands in a powershell script or something of the like that writes all output to text or even to a custom event log.

Harrison Gibbs
  • 369
  • 1
  • 8
  • And with that, we have now another potential answer to the question, "_hey, why don't I see history for a task that I know ran?...oh, it ran during that moment that someone disabled ALL task logging while THEIR task was running_". :-) So do beware of a race condition here: if you use the tip above and your task takes at all long, you are now affecting ALL logging during that time. Still, I appreciate the creative thinking here. It is SUCH a shame that there's no provision to log (or not log) only some tasks. – charlie arehart Apr 09 '21 at 15:16