get_scheduled_tasks
Retrieve information about scheduled tasks on Windows systems. Query all tasks or get detailed status of specific tasks to monitor and manage automated system operations.
Instructions
Retrieve information about scheduled tasks on the system. Can query all tasks or get detailed status of a specific task.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Action to perform | query |
| taskName | No | Name of the specific task (optional) |
Implementation Reference
- index.ts:263-322 (handler)The asynchronous handler function that executes the get_scheduled_tasks tool logic. It checks if the platform is Windows, constructs a PowerShell command based on the 'action' (query or status) and optional 'taskName', executes it using executeCommand, and returns the output or error.async ({ action, taskName }) => { if (!isWindows) { return { content: [ { type: "text", text: "The scheduled tasks tool is only available on Windows. Current platform: " + platform(), }, ], }; } try { let cmd = "powershell.exe -Command \""; if (action === "query") { if (taskName) { cmd += "Get-ScheduledTask -TaskName '" + taskName + "' | Format-List TaskName, State, Description, Author, LastRunTime, NextRunTime, LastTaskResult"; } else { cmd += "Get-ScheduledTask | Select-Object TaskName, State, Description | Format-Table -AutoSize | Out-String"; } } else if (action === "status" && taskName) { cmd += "Get-ScheduledTask -TaskName '" + taskName + "' | Format-List *; " + "Get-ScheduledTaskInfo -TaskName '" + taskName + "' | Format-List *"; } else { return { isError: true, content: [ { type: "text", text: "For 'status' action, taskName parameter is required", }, ], }; } cmd += "\""; const stdout = executeCommand(cmd); return { content: [ { type: "text", text: stdout.toString(), }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error retrieving scheduled tasks: ${error}`, }, ], }; } }
- index.ts:259-262 (schema)Zod schema defining the input parameters for the get_scheduled_tasks tool: 'action' (enum: query or status, defaults to query) and optional 'taskName' (string).{ action: z.enum(["query", "status"]).default("query").describe("Action to perform"), taskName: z.string().optional().describe("Name of the specific task (optional)"), },
- index.ts:256-323 (registration)The server.tool call that registers the get_scheduled_tasks tool, providing the name, description, input schema, and handler function.server.tool( "get_scheduled_tasks", "Retrieve information about scheduled tasks on the system. Can query all tasks or get detailed status of a specific task.", { action: z.enum(["query", "status"]).default("query").describe("Action to perform"), taskName: z.string().optional().describe("Name of the specific task (optional)"), }, async ({ action, taskName }) => { if (!isWindows) { return { content: [ { type: "text", text: "The scheduled tasks tool is only available on Windows. Current platform: " + platform(), }, ], }; } try { let cmd = "powershell.exe -Command \""; if (action === "query") { if (taskName) { cmd += "Get-ScheduledTask -TaskName '" + taskName + "' | Format-List TaskName, State, Description, Author, LastRunTime, NextRunTime, LastTaskResult"; } else { cmd += "Get-ScheduledTask | Select-Object TaskName, State, Description | Format-Table -AutoSize | Out-String"; } } else if (action === "status" && taskName) { cmd += "Get-ScheduledTask -TaskName '" + taskName + "' | Format-List *; " + "Get-ScheduledTaskInfo -TaskName '" + taskName + "' | Format-List *"; } else { return { isError: true, content: [ { type: "text", text: "For 'status' action, taskName parameter is required", }, ], }; } cmd += "\""; const stdout = executeCommand(cmd); return { content: [ { type: "text", text: stdout.toString(), }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error retrieving scheduled tasks: ${error}`, }, ], }; } } );