peass-ng/PEASS-ng · error · ArgumentOutOfRangeException

A maximum of 32 values is allowed.

Error message

A maximum of 32 values is allowed.

What it means

Task.Run enforces the Task Scheduler's limit that at most 32 command-line parameters can be passed to a launched task instance. Passing more than 32 values triggers this error; the count of the parameters array is the invalid input.

Source

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

        /// <a href="https://docs.microsoft.com/en-us/windows/desktop/taskschd/task-actions#using-variables-in-action-properties">Task Actions</a>.
        /// </para>
        /// </param>
        /// <returns>A <see cref="RunningTask"/> instance that defines the new instance of the task.</returns>
        /// <example>
        /// <code lang="cs">
        ///<![CDATA[
        /// // Run the current task with a parameter
        /// var runningTask = myTaskInstance.Run("info");
        /// Console.Write(string.Format("Running task's current action is {0}.", runningTask.CurrentAction));
        ///]]>
        /// </code>
        /// </example>
        public RunningTask Run(params string[] parameters)
        {
            if (v2Task != null)
            {
                if (parameters.Length > 32)
                    throw new ArgumentOutOfRangeException(nameof(parameters), "A maximum of 32 values is allowed.");
                if (TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5 && parameters.Any(p => (p?.Length ?? 0) >= 260))
                    throw new ArgumentOutOfRangeException(nameof(parameters), "On systems prior to Windows 10, all individual parameters must be less than 260 characters.");
                var irt = v2Task.Run(parameters.Length == 0 ? null : parameters);
                return irt != null ? new RunningTask(TaskService, v2Task, irt) : null;
            }

            v1Task.Run();
            return new RunningTask(TaskService, v1Task);
        }

        /// <summary>Runs the registered task immediately using specified flags and a session identifier.</summary>
        /// <param name="flags">Defines how the task is run.</param>
        /// <param name="sessionID">
        /// <para>The terminal server session in which you want to start the task.</para>
        /// <para>
        /// If the <see cref="TaskRunFlags.UseSessionId"/> value is not passed into the <paramref name="flags"/> parameter, then the value
        /// specified in this parameter is ignored.If the <see cref="TaskRunFlags.UseSessionId"/> value is passed into the flags parameter
        /// and the sessionID value is less than or equal to 0, then an invalid argument error will be returned.

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Reduce the parameters to 32 or fewer, combining values (e.g. quoted or delimited strings).
  2. Pass bulk data via a file path or environment/config file rather than as parameters.
  3. Split the workload across multiple task runs if more than 32 values are truly needed.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs:1402 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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