{"record":{"id":"7fc1a4aa312ae1de","repo":"peass-ng/PEASS-ng","slug":"enumeration-of-task-history-not-available-on-syste","errorCode":null,"errorMessage":"Enumeration of task history not available on systems prior to Windows Vista and Windows Server 2008.","messagePattern":"Enumeration of task history not available on systems prior to Windows Vista and Windows Server 2008\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskEvent.cs","lineNumber":762,"sourceCode":"                sb.Append(']');\n            }\n            if (!string.IsNullOrEmpty(taskName))\n            {\n                if (sb.Length == 1)\n                    sb.Append('[');\n                else\n                    sb.Append(\"]\" + AND + \"*[\");\n                sb.AppendFormat(\"EventData[Data[@Name='TaskName']='{0}']\", taskName);\n            }\n            if (sb.Length > 1)\n                sb.Append(']');\n            return string.Format(queryString, sb);\n        }\n\n        private void Initialize(string machineName, string query, bool revDir, string domain = null, string user = null, string password = null)\n        {\n            if (!IsVistaOrLater)\n                throw new NotSupportedException(\"Enumeration of task history not available on systems prior to Windows Vista and Windows Server 2008.\");\n\n            System.Security.SecureString spwd = null;\n            if (password != null)\n            {\n                spwd = new System.Security.SecureString();\n                foreach (char c in password)\n                    spwd.AppendChar(c);\n            }\n\n            Query = new EventLogQuery(TSEventLogPath, PathType.LogName, query) { ReverseDirection = revDir };\n            if (machineName != null && machineName != \".\" && !machineName.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase))\n                Query.Session = new EventLogSession(machineName, domain, user, spwd, SessionAuthentication.Default);\n        }\n\n        /// <summary>\n        /// Gets the total number of events for this task.\n        /// </summary>\n        public long Count","sourceCodeStart":744,"sourceCodeEnd":780,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskEvent.cs#L744-L780","documentation":"TaskEventLog.Initialize throws NotSupportedException when the current OS is older than Windows Vista / Server 2008. Task history enumeration relies on the Windows Event Log (Vista+) channel 'Microsoft-Windows-TaskScheduler/Operational', which does not exist on XP/2003. The library intentionally fails fast instead of returning empty results.","triggerScenarios":"Constructing a TaskEventLog (e.g. new TaskEventLog() or with a machine name/query) on an OS where Environment.OSVersion is below 6.0, causing Initialize to run its IsVistaOrLater check and throw.","commonSituations":"Running winPEAS or an app built on Microsoft.Win32.TaskScheduler on legacy Windows XP/Server 2003 machines, or in environments where the OS version check wrongly reports pre-Vista (compatibility shims, old .NET targets).","solutions":["Check TaskEventLog.IsVistaOrLater (or OS version >= 6.0) before constructing TaskEventLog and skip history enumeration on legacy systems","Wrap TaskEventLog construction in try/catch for NotSupportedException and degrade gracefully (skip task history)","Target/require Windows Vista or newer for task-history functionality"],"exampleFix":"// before\nvar log = new TaskEventLog();\nforeach (var e in log) Process(e);\n// after\nif (TaskEventLog.IsVistaOrLater)\n{\n    var log = new TaskEventLog();\n    foreach (var e in log) Process(e);\n}","handlingStrategy":"fallback","validationCode":"bool canEnumerate = Environment.OSVersion.Version.Major >= 6;","typeGuard":null,"tryCatchPattern":"try { var log = new TaskEventLog(); /* enumerate */ }\ncatch (NotSupportedException) { /* skip task history on pre-Vista */ }","preventionTips":["Check OS version (>= 6.0) before using event-log-backed task history","Encapsulate TaskEventLog creation in a helper that returns null on legacy OS","Document the Vista+ requirement for history features"],"tags":["windows","taskscheduler","notsupported","os-version"],"backgroundTag":"platform-not-supported","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}