{"record":{"id":"7e09cfcdabf8b0c3","repo":"peass-ng/PEASS-ng","slug":"a-maximum-of-32-actions-is-allowed-within-a-single","errorCode":null,"errorMessage":"A maximum of 32 actions is allowed within a single task.","messagePattern":"A maximum of 32 actions is allowed within a single task\\.","errorType":"exception","errorClass":"System.ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/Action.cs","lineNumber":209,"sourceCode":"        {\n            if (Id != null)\n                iTask.SetDataItem(\"ActionId\", Id);\n            var bindable = this as IBindAsExecAction;\n            if (bindable != null)\n                iTask.SetDataItem(\"ActionType\", InternalActionType.ToString());\n            unboundValues.TryGetValue(\"Path\", out var o);\n            iTask.SetApplicationName(bindable != null ? ExecAction.PowerShellPath : o?.ToString() ?? string.Empty);\n            unboundValues.TryGetValue(\"Arguments\", out o);\n            iTask.SetParameters(bindable != null ? ExecAction.BuildPowerShellCmd(ActionType.ToString(), GetPowerShellCommand()) : o?.ToString() ?? string.Empty);\n            unboundValues.TryGetValue(\"WorkingDirectory\", out o);\n            iTask.SetWorkingDirectory(o?.ToString() ?? string.Empty);\n        }\n\n        internal virtual void Bind(ITaskDefinition iTaskDef)\n        {\n            var iActions = iTaskDef.Actions;\n            if (iActions.Count >= ActionCollection.MaxActions)\n                throw new ArgumentOutOfRangeException(nameof(iTaskDef), @\"A maximum of 32 actions is allowed within a single task.\");\n            CreateV2Action(iActions);\n            Marshal.ReleaseComObject(iActions);\n            foreach (var key in unboundValues.Keys)\n            {\n                try { ReflectionHelper.SetProperty(iAction, key, unboundValues[key]); }\n                catch (TargetInvocationException tie) { throw tie.InnerException; }\n                catch { }\n            }\n            unboundValues.Clear();\n        }\n\n        /// <summary>Copies the properties from another <see cref=\"Action\"/> the current instance.</summary>\n        /// <param name=\"sourceAction\">The source <see cref=\"Action\"/>.</param>\n        internal virtual void CopyProperties([NotNull] Action sourceAction) => Id = sourceAction.Id;\n\n        internal abstract void CreateV2Action(IActionCollection iActions);\n\n        internal abstract string GetPowerShellCommand();","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/Action.cs#L191-L227","documentation":"When an Action is bound to a Task Scheduler v2 task definition, the library checks the current count against ActionCollection.MaxActions (32, the Windows Task Scheduler limit). If 32 or more actions already exist, Bind throws ArgumentOutOfRangeException. Windows itself will not accept more than 32 actions in one task.","triggerScenarios":"Adding a 33rd action to a task definition before registration; programmatically building a task from a loop/list of executables without capping the list; deserializing a task XML with more than 32 actions.","commonSituations":"Bulk-deployment scripts that create one task with an unbounded list of commands; migration tools importing legacy batch scripts into a single task; generated configurations where each update appends an action instead of replacing them.","solutions":["Check ActionCollection.Count before Add and cap at 32; split overflow into additional tasks","Group related commands into a single ExecAction running a script/cmd wrapper to reduce action count","Clear or rebuild the action collection when re-configuring a task instead of appending each time","Catch ArgumentOutOfRangeException in Bind/Add and surface a clear 'task full' message"],"exampleFix":"// before\nforeach (var exe in exes) task.Definition.Actions.Add(new ExecAction(exe, args));\n// after\nforeach (var batch in exes.Chunk(32))\n{\n    var t = TaskService.Instance.CreateTask(...);\n    foreach (var exe in batch) t.Definition.Actions.Add(new ExecAction(exe, args));\n    t.RegisterTaskDefinition(...);\n}","handlingStrategy":"validation","validationCode":"if (actions.Count + newActions.Count > 32)\n    throw new InvalidOperationException(\"Task action limit (32) would be exceeded; split into multiple tasks.\");","typeGuard":null,"tryCatchPattern":"try { def.Actions.Add(action); }\ncatch (ArgumentOutOfRangeException)\n{\n    log.Error(\"Task already has the maximum 32 actions; create an additional task.\");\n}","preventionTips":["Cap action lists at 32 and chunk bulk workloads into multiple tasks","Batch related commands into a single ExecAction running a script","Rebuild (clear) the action collection on reconfiguration instead of appending","Check Count before every Add in loops"],"tags":["csharp","taskscheduler","limit-exceeded"],"backgroundTag":"task-action-limit-exceeded","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}