peass-ng/PEASS-ng · error · InvalidOperationException

The current version of the native library (1.{osLibMinorVer}

Error message

The current version of the native library (1.{osLibMinorVer}) does not support the version of the "{iTask.Name}" task ({xmlVer})

What it means

When registering/validating task XML, a COMException with HRESULT 0x80041318 (SCHED_E_INVALIDVALUE — incorrect XML value) that is not resolvable by downgrading the version causes this InvalidOperationException when throwError is true. It means the task's XML declares a version the local native library cannot represent.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs:1652

                    if (newMinor > osLibMinorVer && throwError)
                        throw new InvalidOperationException($"The current version of the native library (1.{osLibMinorVer}) does not support the original or minimum version of the \"{iTask.Name}\" task ({xmlVer}/1.{newMinor}). This is likely due to attempting to read the remote tasks of a newer version of Windows from a down-level client.");

                    if (newMinor != xmlVer.Minor)
                    {
                        dd.Version = new Version(1, newMinor);
                        var def = svc.v2TaskService.NewTask(0);
                        def.XmlText = dd.Xml;
                        return def;
                    }
                }
                return iTask.Definition;
            }
            catch (COMException comEx)
            {
                if (throwError)
                {
                    if ((uint)comEx.ErrorCode == 0x80041318 && xmlVer.Minor != osLibMinorVer) // Incorrect XML value
                        throw new InvalidOperationException($"The current version of the native library (1.{osLibMinorVer}) does not support the version of the \"{iTask.Name}\" task ({xmlVer})");
                    throw;
                }
            }
            catch
            {
                if (throwError)
                    throw;
            }
            return null;
        }

        internal static ITaskDefinition GetV2StrippedDefinition(TaskService svc, IRegisteredTask iTask)
        {
            try
            {
                var dd = new DefDoc(iTask.Xml);
                var xmlVer = dd.Version;
                if (xmlVer.Minor > osLibMinorVer)

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Ensure the XML's <Task version="1.x"> attribute matches a version the local OS supports
  2. Re-export the task XML from an OS with the same Task Scheduler version
  3. Set throwError=false to tolerate the mismatch (library will attempt adjustment)
  4. Edit the XML manually to lower the version and remove unsupported elements

Example fix

// before
folder.RegisterTaskDocument(name, xmlFromWin10Machine, throwError: true);
// after
var xml = xmlFromWin10Machine.Replace("version=\"1.6\"", "version=\"1.4\"");
folder.RegisterTaskDocument(name, xml, throwError: true);
Defensive patterns

Strategy: try-catch

Validate before calling

var m = Regex.Match(xml, "<Task[^>]*version=\"1\.(\\d+)\"");
if (m.Success && int.Parse(m.Groups[1].Value) > osLibMinorVer)
    Console.WriteLine("XML version too new for this machine");

Try / catch

try { folder.RegisterTaskDocument(name, xml, throwError: true); }
catch (InvalidOperationException ex) when (ex.Message.Contains("does not support the version"))
{ /* lower xml version or re-export on matching OS */ }

Prevention

When it happens

Trigger: Calling DefinitionalUpdate/Register or reading a task whose XML version (xmlVer) has a minor version different from the local library's (osLibMinorVer), producing COM error 0x80041318, with throwError enabled.

Common situations: Importing task XML exported from a newer Windows version; copying .xml task definitions between machines with different Task Scheduler versions; programmatic XML edits that alter the version attribute.

Related errors


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