Search code examples
windowspowershellscheduled-tasks

Powershell monitor task scheduler


hi i found the following ps script that stores all the results of the enabled tasks

Get-ScheduledTask | where state -EQ 'ready' | Get-ScheduledTaskInfo | 
Export-Csv -NoTypeInformation -Path C:\fso\scheduledTasksResults.csv

is it possible only store tasks with no path under Taskpath which are ones i created?

this allows to me ensure their running okay


Solution

  • Sure, you can add a Where-Object Filter after the Get-ScheduledTaskInfo just like you use after Get-Scheduledtask full command would look like

    Get-ScheduledTask | where state -EQ 'ready' | 
      Get-ScheduledTaskInfo | where !TaskPath | 
        Export-Csv -NoTypeInformation -Path C:\fso\scheduledTasksResults.csv
    

    the above will find any task with a blank TaskPath property.

    However after looking at my own task scheduler it looks like you will still have a taskpath on tasks you created yourself, it will just be '', so in that case the correct command will be

    Get-ScheduledTask | where state -EQ 'ready' | 
      Get-ScheduledTaskInfo | where TaskPath -eq '\' | 
        Export-Csv -NoTypeInformation -Path C:\fso\scheduledTasksResults.csv