powershelltaskscheduler

How to filter some particular tasks using get-scheduledTasks from task scheduler of a remote machine


I am trying to get list of scheduled tasks from some remote machines using the get-scheduledTasks cmdlet. How to list those tasks and filter out only few tasks out of them and perform actions based on the presence of those tasks


Solution

  • $name="Start of task name or absolute name"
    $servers="server01","server02","server03"
    
    $tasks = $servers | % { Invoke-Command -ComputerName $_ -ScriptBlock { Get-ScheduledTask | ? { $_.Name.StartsWith($name) } }
    

    What you then do depends on what you want to do with those tasks.