{"record":{"id":"6e96aa10bbb44fc0","repo":"peass-ng/PEASS-ng","slug":"only-a-single-nameof-action-execaction-is-suppo","errorCode":null,"errorMessage":"Only a single {nameof(Action.ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value.","messagePattern":"Only a single (.+?) is supported unless the (.+?) property includes the (.+?) value\\.","errorType":"exception","errorClass":"NotV1SupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs","lineNumber":294,"sourceCode":"            get => this[index];\n            set => this[index] = (Action)value;\n        }\n\n        /// <summary>Adds an action to the task.</summary>\n        /// <typeparam name=\"TAction\">A type derived from <see cref=\"Action\"/>.</typeparam>\n        /// <param name=\"action\">A derived <see cref=\"Action\"/> class.</param>\n        /// <returns>The bound <see cref=\"Action\"/> that was added to the collection.</returns>\n        [NotNull]\n        public TAction Add<TAction>([NotNull] TAction action) where TAction : Action\n        {\n            if (action == null)\n                throw new ArgumentNullException(nameof(action));\n            if (v2Def != null)\n                action.Bind(v2Def);\n            else\n            {\n                if (!SupportV1Conversion && (v1Actions.Count >= 1 || !(action is Action.ExecAction)))\n                    throw new NotV1SupportedException($\"Only a single {nameof(Action.ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value.\");\n                v1Actions.Add(action);\n                SaveV1Actions();\n            }\n            OnNotifyPropertyChanged(nameof(Count));\n            OnNotifyPropertyChanged(IndexerName);\n            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, action));\n            return action;\n        }\n\n        /// <summary>Adds an <see cref=\"Action.ExecAction\"/> to the task.</summary>\n        /// <param name=\"path\">Path to an executable file.</param>\n        /// <param name=\"arguments\">Arguments associated with the command-line operation. This value can be null.</param>\n        /// <param name=\"workingDirectory\">\n        /// Directory that contains either the executable file or the files that are used by the executable file. This value can be null.\n        /// </param>\n        /// <returns>The bound <see cref=\"Action.ExecAction\"/> that was added to the collection.</returns>\n        [NotNull]\n        public Action.ExecAction Add([NotNull] string path, [CanBeNull] string arguments = null, [CanBeNull] string workingDirectory = null) =>","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/ActionCollection.cs#L276-L312","documentation":"On Task Scheduler v1 (Windows XP/Server 2003) only one action is supported natively; the library emulates multiple actions via PowerShell conversion, but only when PowerShellConversion includes PowerShellActionPlatformOption.Version1. Add throws NotV1SupportedException when, under v1, PowerShell conversion is off and either an action already exists or the new action is not an ExecAction.","triggerScenarios":"Calling Add (directly or via AddRange/Insert/ReadXml) on a task targeting v1 with PowerShellConversion not including Version1, when: a second action is added after an ExecAction, or the added action is an EmailAction/ShowMessageAction/COM handler action.","commonSituations":"Building tasks that must run on legacy Windows; loading a multi-action task definition into a v1 TaskService instance without enabling PowerShell conversion; adding an EmailAction on XP-era compatibility paths.","solutions":["Set task.Definition.Actions.PowerShellConversion = PowerShellActionPlatformOption.Version1 before adding multiple/non-Exec actions under v1","Target Task Scheduler 2.0 (Vista+) so multiple native actions are supported","Consolidate v1 logic into a single ExecAction running a script that performs all steps","Catch NotV1SupportedException and either upgrade the platform target or warn about lost functionality"],"exampleFix":"// before\nvar def = ts.CreateTask(...); // v1 target\ndef.Actions.Add(new ExecAction(\"a.exe\"));\ndef.Actions.Add(new ExecAction(\"b.exe\")); // throws\n// after\ndef.Actions.PowerShellConversion = PowerShellActionPlatformOption.Version1;\ndef.Actions.Add(new ExecAction(\"a.exe\"));\ndef.Actions.Add(new ExecAction(\"b.exe\"));","handlingStrategy":"try-catch","validationCode":"static bool CanAddActionV1(ActionCollection actions, TaskAction action) =>\n    actions.SupportV1Conversion ||\n    (actions.Count == 0 && action is Action.ExecAction);","typeGuard":null,"tryCatchPattern":"try { def.Actions.Add(action); }\ncatch (NotV1SupportedException)\n{\n    log.Warn(\"Target platform v1 supports only one ExecAction; enable PowerShellConversion.Version1 or upgrade to v2.\");\n}","preventionTips":["Enable PowerShellConversion = PowerShellActionPlatformOption.Version1 when multi-action v1 support is required","Target Task Scheduler 2.0 (Vista+) for native multi-action support","Consolidate v1 workloads into a single ExecAction script","Validate action type and count against v1 constraints before Add/AddRange/Insert"],"tags":["csharp","taskscheduler","v1-compatibility","powershell-conversion"],"backgroundTag":"v1-action-not-supported","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}