Query schtasks using Powershell

You could try to use schtasks, which will leave you parsing text. This is almost always error prone, and definitely more difficult than it is to take the output of a command.

There happens to be a TaskScheduler module in the PowerShellPack. Once you install the PowerShell pack, to get all of the scheduled tasks, use:

Import-Module TaskScheduler
Get-ScheduledTask -Recurse

Since these are real objects, to find a task of a particular name, you can use:

Get-ScheduledTask -Recurse |  Where-Object { $_.Name -like "*Task*"}

In general, you will find that the PowerShell community has taken a lot of harder to use command lines, like schtasks, and turned them into easy-to-use cmdlets, like Get-ScheduledTask.

See Also:

Sending Automated Emails using the TaskScheduler Module

Hope this helps


if you don't need to do it in powershell then the following will work

schtasks /query | findstr /i "mytask"

ps version
schtasks /query | ?{$_ -like 'mytask'}


Here's a blog post I wrote about doing this. Essentially, I took the output of the /FO LIST /V, wrote that to a file, and imported it back in as objects using import-csv


You may try:

schtasks /query /FO CSV | ConvertFrom-CSV | Where { $_.TaskName -eq "myTask" } 

The trick is in converting output to CSV first, and then back to a powershell object.