{"record":{"id":"76bab0c78123ca9c","repo":"peass-ng/PEASS-ng","slug":"specified-argument-was-out-of-the-range-of-valid-v-76bab0","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'createType')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'createType'\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs","lineNumber":572,"sourceCode":"\n            switch (createType)\n            {\n                case TaskCreation.Create:\n                case TaskCreation.CreateOrUpdate:\n                case TaskCreation.Disable:\n                case TaskCreation.Update:\n                    if (createType == TaskCreation.Disable)\n                        definition.Settings.Enabled = false;\n                    definition.V1Save(path);\n                    break;\n                case TaskCreation.DontAddPrincipalAce:\n                    throw new NotV1SupportedException(\"Security settings are not available on Task Scheduler 1.0.\");\n                case TaskCreation.IgnoreRegistrationTriggers:\n                    throw new NotV1SupportedException(\"Registration triggers are not available on Task Scheduler 1.0.\");\n                case TaskCreation.ValidateOnly:\n                    throw new NotV1SupportedException(\"XML validation not available on Task Scheduler 1.0.\");\n                default:\n                    throw new ArgumentOutOfRangeException(nameof(createType), createType, null);\n            }\n            return new Task(TaskService, definition.v1Task);\n        }\n\n        /// <summary>\n        /// Applies access control list (ACL) entries described by a <see cref=\"TaskSecurity\"/> object to the file described by the current <see cref=\"TaskFolder\"/> object.\n        /// </summary>\n        /// <param name=\"taskSecurity\">A <see cref=\"TaskSecurity\"/> object that describes an access control list (ACL) entry to apply to the current folder.</param>\n        public void SetAccessControl([NotNull] TaskSecurity taskSecurity) { taskSecurity.Persist(this); }\n\n        /// <summary>\n        /// Sets the security descriptor for the folder. Not available to Task Scheduler 1.0.\n        /// </summary>\n        /// <param name=\"sd\">The security descriptor for the folder.</param>\n        /// <param name=\"includeSections\">Section(s) of the security descriptor to set.</param>\n        [Obsolete(\"This method will be removed in deference to the SetAccessControl and SetSecurityDescriptorSddlForm methods.\")]\n        public void SetSecurityDescriptor([NotNull] GenericSecurityDescriptor sd, SecurityInfos includeSections = Task.defaultSecurityInfosSections) { SetSecurityDescriptorSddlForm(sd.GetSddlForm((AccessControlSections)includeSections)); }\n","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs#L554-L590","documentation":"TaskFolder.RegisterTaskDefinition throws ArgumentOutOfRangeException when the TaskCreation value passed as createType is not one of the creation types supported by Task Scheduler 1.0 (e.g. IgnoreRegistrationTriggers, ValidateOnly, or other unsupported flags). The library only supports a subset of TaskCreation values on the legacy v1 scheduler, and anything falling through the switch's default case is rejected with this exception naming the 'createType' parameter.","triggerScenarios":"Calling TaskFolder.RegisterTask or RegisterTaskDefinition on a system/folder bound to Task Scheduler 1.0 (v2Folder == null) with createType set to TaskCreation.IgnoreRegistrationTriggers, TaskCreation.ValidateOnly, or any other TaskCreation value not handled by the v1 switch.","commonSituations":"Code written against Task Scheduler 2.0 features (XML validation, registration triggers) being run on Windows XP / Server 2003, or on a task path/folder that the library resolved to the v1 root folder; copied sample code using ValidateOnly without a v2 check.","solutions":["Check TaskService.HighestSupportedVersion / use a v2-compatible connection before using advanced TaskCreation values","Use TaskCreation.Create or another v1-supported value when targeting Task Scheduler 1.0","Catch NotV1SupportedException/ArgumentOutOfRangeException and fall back to a simplified registration path"],"exampleFix":"// before\nfolder.RegisterTaskDefinition(name, def, TaskCreation.ValidateOnly, null, null, TaskLogonType.InteractiveToken);\n// after\nif (ts.HighestSupportedVersion >= TaskSchedulerVersion.V2)\n    folder.RegisterTaskDefinition(name, def, TaskCreation.ValidateOnly, null, null, TaskLogonType.InteractiveToken);\nelse\n    folder.RegisterTaskDefinition(name, def, TaskCreation.Create, null, null, TaskLogonType.InteractiveToken);","handlingStrategy":"validation","validationCode":"bool v1 = ts.HighestSupportedVersion < TaskSchedulerVersion.V2;\nif (v1 && (createType == TaskCreation.IgnoreRegistrationTriggers || createType == TaskCreation.ValidateOnly))\n    throw new NotSupportedException(\"TaskCreation value unsupported on Task Scheduler 1.0.\");","typeGuard":null,"tryCatchPattern":"try { folder.RegisterTaskDefinition(name, def, createType, userId, pwd, logonType); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"createType\") { /* fall back to TaskCreation.Create */ }","preventionTips":["Check TaskService.HighestSupportedVersion before using v2-only TaskCreation values","Stick to TaskCreation.Create/CreateOrUpdate for maximum compatibility","Centralize task registration in one helper that gates advanced options"],"tags":["task-scheduler","argumentoutofrange","v1-compatibility"],"backgroundTag":"task-scheduler-v1-unsupported-feature","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}