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
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).
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.
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.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With