schtasks /query /fo LIST /tn "xyz"
I want to filter and choose some specific tasks from the task scheduler and if those tasks are present then perform certain actions. How do I apply this filter to choose more than one taskname?
This command will show all Scheduled Tasks on your computer:
Get-ScheduledTask
To Filter to just the task you need, you would pipe it to the Where-Object command. Example to show all tasks related to Windows Defender AV:
Get-ScheduledTask | Where-Object {$_.Taskname -match 'Defender'}
Then store those task objects in a variable:
$DefenderTasks = Get-ScheduledTask | Where-Object {$_.Taskname -match 'Defender'}
Then you can perform an operation on the variable:
Set-ScheduledTask -Taskname $DefenderTasks <something>
Type in the following to get help and examples:
Get-Help Set-ScheduledTask -Full