Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use powershell to find scheduled tasks set to wake the computer

I've downloaded the powershell script located here: http://gallery.technet.microsoft.com/scriptcenter/Get-Scheduled-tasks-from-3a377294

However, this doesn't give me the piece of info I'm looking for. i want to see if any task is set to wake the pc in order to run that task. I see where in the script it's looping through and displaying the properties for each task. But I'm not familiar with working with powershell or the Schedule.Service object so i don't know what property that is. Could someone eithe tell me a way to get a list of tasks set to wake the pc? or just tell me how to edit that script so it displays that bit of info.

thanks

like image 763
merk Avatar asked Dec 11 '13 20:12

merk


People also ask

How do I wake up my computer on Task Scheduler?

Use Task SchedulerGo to the Start menu search bar, type in 'task scheduler,' and select the best match. In the Task Scheduler, click on Action > Create Task… Set a name for your task. We'll set the name as 'wake up'.

How do I view scheduled tasks in PowerShell?

To retrieve the existing tasks in the task scheduler using PowerShell, we can use the PowerShell command Get-ScheduledTask. We can use the Task Scheduler GUI to retrieve the scheduled tasks. To retrieve using PowerShell, use the Get-ScheduledTask command.

Will Task Scheduler wake computer?

Wake Your PC Automatically Using the Task Scheduler. You can configure your PC to wake automatically using a Windows app called the Task Scheduler. Type Task Scheduler in the Windows Search Bar and select the Best Match. In the right-hand side panel of the Task Scheduler window, click Create Task.

How do I see scheduled tasks running?

If you open Event Viewer and go to: Event Viewer (Local) / Applications and Services Logs / Microsoft / Windows / TaskScheduler / Optional, you will see all the Task Histories.


3 Answers

This can be done in a one-liner:

Get-ScheduledTask | where {$_.settings.waketorun}

Get-ScheduledTask is available in Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2.

like image 82
Dan Rice Avatar answered Sep 29 '22 17:09

Dan Rice


on win8.1:

$tasks = Get-ScheduledTask

ForEach ($task in $tasks)
{
    if($task.settings.waketorun -eq 'True')
        {"$($task.taskname)"}
}
like image 35
pwrsh3ll Avatar answered Sep 29 '22 16:09

pwrsh3ll


That information should be down in the xml. Edit: Graimer is correct that this is not using the same script that was linked.
This uses Get-ScheduledTask from the TaskScheduler Module in the PowerShellPack, which can be downloade from here: http://archive.msdn.microsoft.com/PowerShellPack

$tasks = Get-ScheduledTask -ComputerName <ComputerName>

ForEach ($task in $tasks)
 {
   $xml = [xml]$task.xml
   if ($xml.task.settings.waketorun -eq 'True')
     { "Task $($task.name) is set to WakeToRun" }
 } 

or simply

 Get-ScheduledTask | select TaskName,TaskPath,@{name="Aufweckung.";expression={$_.Settings.WakeToRun}} -ExpandProperty Triggers | ft -AutoSize -Wrap
like image 39
mjolinor Avatar answered Sep 29 '22 16:09

mjolinor