Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I `Enable All Tasks History` in PowerShell?

In the task scheduler GUI it is easy to Enable All Tasks History

See also https://stackoverflow.com/questions/11013132/how-can-i-enable-the-windows-server-task-scheduler-history-recording

Enable All Tasks History button in GUI

How can I Enable All Tasks History through PowerShell?

I have looked at Set-ScheduledTask and New-ScheduledTask, but nothing useful there (as far as I can see).

like image 963
steenhulthin Avatar asked Apr 22 '14 18:04

steenhulthin


People also ask

How do I turn on task history?

Enable history on Task Scheduler Open Task Scheduler on Windows 11. Right-click the Task Scheduler Library folder. Select the “Enable All Tasks History” option to enable the feature. (Optional) Select the “Disable All Tasks History” option to disable the feature.

How do I see my work scheduled task history?

Windows Scheduled tasks history is written to an event log. If you open Event Viewer and go to: Event Viewer (Local) / Applications and Services Logs / Microsoft / Windows / TaskScheduler / Optional, you will see all the Task Histories.

How do I list tasks in PowerShell?

To get a list of scheduled tasks on a remote computer, you can use the -CimSession parameter. You will need PowerShell Remoting enabled for this to work.


1 Answers

After doing a bunch of research, I found that the History tab is just a view of a windows event log, displayed using MMC snapin. So really, all that button is doing is disabling / enabling the windows event log for the task scheduler. Here is the script to automate pushing of that button :

$logName = 'Microsoft-Windows-TaskScheduler/Operational'
$log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $logName
$log.IsEnabled=$true
$log.SaveChanges()

Sources that got me there: http://windows.microsoft.com/en-us/windows-vista/automate-tasks-with-task-scheduler-from-windows-vista-inside-out
http://www.powershellmagazine.com/2013/07/15/pstip-how-to-enable-event-logs-using-windows-powershell/

like image 96
Cole9350 Avatar answered Sep 21 '22 06:09

Cole9350