peass-ng/PEASS-ng · error · System.Xml.XmlException
Invalid days of the week element.
Error message
Invalid days of the week element.
What it means
When reading a trigger definition from XML, an unknown/invalid element name inside the DaysOfWeek block cannot be parsed into the DaysOfTheWeek enum, and the library rethrows it as XmlException('Invalid days of the week element.'). The XML contains a day-of-week value outside the expected names (Monday..Sunday, AllDays, etc.).
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Trigger.cs:2637
{
switch (reader.LocalName)
{
case "WeeksInterval":
WeeksInterval = (short)reader.ReadElementContentAsInt();
break;
case "DaysOfWeek":
reader.Read();
DaysOfWeek = 0;
while (reader.MoveToContent() == System.Xml.XmlNodeType.Element)
{
try
{
DaysOfWeek |= (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), reader.LocalName);
}
catch
{
throw new System.Xml.XmlException("Invalid days of the week element.");
}
reader.Read();
}
reader.ReadEndElement();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
}
/// <summary>Writes the subclass XML for V1 streams.</summary>
/// <param name="writer">The writer.</param>
private void WriteMyXml(System.Xml.XmlWriter writer)
{View on GitHub (pinned to 53fb989abc)
Solutions
- Fix the DaysOfWeek XML elements to use canonical English enum names (Monday, Tuesday, ...)
- Validate the XML against the Task Scheduler schema before import
- Wrap ReadXml in try-catch for XmlException and repair or reject the file
Example fix
// before <DaysOfWeek><Mon/><Wed/></DaysOfWeek> // after <DaysOfWeek><Monday/><Wednesday/></DaysOfWeek>
Defensive patterns
Strategy: validation
Validate before calling
static readonly string[] ValidDays = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
static bool DaysOfWeekXmlValid(XElement days) =>
days?.Elements().All(e => ValidDays.Contains(e.Name.LocalName, StringComparer.Ordinal)) ?? true; Try / catch
try { trigger.ReadXml(reader); }
catch (System.Xml.XmlException ex) when (ex.Message.Contains("days of the week")) { /* repair DaysOfWeek section or reject file */ } Prevention
- Generate task XML only with canonical English day names
- Validate imports against the Task Scheduler XML schema
- Never hand-edit or localize DaysOfWeek elements in task XML
When it happens
Trigger: Importing/reading task XML (ReadXml on a trigger) whose <DaysOfWeek> child element name is not a valid DaysOfTheWeek enum name — misspelled day, localized day names, or numeric values.
Common situations: Hand-edited or third-party-generated task XML with e.g. <Mon/> instead of <Monday/>, localized XML from non-English tooling, or corrupted export files.
Related errors
- Trigger.Repetition.Interval must be less than Trigger.Repeti
- Resources.Error_TriggerEndBeforeStart
- The current version of the native library (1.{osLibMinorVer}
- Task definition does not contain a version.
- Specified argument was out of the range of valid values. (Pa
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/67774381528e1b09.
Report an issue: GitHub.