peass-ng/PEASS-ng · error · NotSupportedException

Task history not available on systems prior to Windows Vista

Error message

Task history not available on systems prior to Windows Vista and Windows Server 2008.

What it means

The Enabled setter on TaskEventLog throws NotSupportedException when IsVistaOrLater is false. Enabling/disabling the Task Scheduler operational event log requires the Vista+ EventLogConfiguration API, which is unavailable on XP/2003.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskEvent.cs:822

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="TaskEventLog" /> is enabled.
        /// </summary>
        /// <value>
        /// <c>true</c> if enabled; otherwise, <c>false</c>.
        /// </value>
        public bool Enabled
        {
            get
            {
                if (!IsVistaOrLater)
                    return false;
                using (var cfg = new EventLogConfiguration(TSEventLogPath, Query.Session))
                    return cfg.IsEnabled;
            }
            set
            {
                if (!IsVistaOrLater)
                    throw new NotSupportedException("Task history not available on systems prior to Windows Vista and Windows Server 2008.");
                using (var cfg = new EventLogConfiguration(TSEventLogPath, Query.Session))
                {
                    if (cfg.IsEnabled != value)
                    {
                        cfg.IsEnabled = value;
                        cfg.SaveChanges();
                    }
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to enumerate in reverse when calling the default enumerator (typically with foreach statement).
        /// </summary>
        /// <value>
        ///   <c>true</c> if enumerates in reverse (newest to oldest) by default; otherwise, <c>false</c> to enumerate oldest to newest.
        /// </value>
        [System.ComponentModel.DefaultValue(false)]

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Guard the Enabled assignment with an OS version check (>= 6.0) and skip on legacy systems
  2. Catch NotSupportedException around the setter and log/handle the unsupported case
  3. Enable task history only on Vista+ machines where the EventLog channel exists

Example fix

// before
log.Enabled = true;
// after
if (TaskEventLog.IsVistaOrLater) log.Enabled = true;
Defensive patterns

Strategy: validation

Validate before calling

if (Environment.OSVersion.Version.Major >= 6) log.Enabled = value;

Try / catch

try { log.Enabled = true; }
catch (NotSupportedException) { /* enabling history unsupported pre-Vista */ }

Prevention

When it happens

Trigger: Setting the TaskEventLog.Enabled property (e.g. log.Enabled = true) on a pre-Vista system, hitting the IsVistaOrLater guard before EventLogConfiguration is created.

Common situations: Code that enables task-history logging as part of setup or audit tooling running on legacy Windows; scripts that unconditionally toggle the TaskScheduler operational channel.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/815d44d859b4627a. Report an issue: GitHub.