0

I have installed Powershell 4.0 on my OS that is Windows Server 2008 R2.

I wanted to create ScheduledTasks by using Scheduled Tasks Cmdlets but it seems they are available only for Windows Server 2012 or Windows 8.1.

QUESTION: What is the shortest way to create scheduled tasks via Powershell 4.0 on Windows Server 2008 R2?

pencilCake
  • 51,323
  • 85
  • 226
  • 363

1 Answers1

1

You could use the TaskScheduler module released as part of the PowerShell Pack. Here is a sample of what you can do with that module:

New-task | 
    Add-TaskTrigger -DayOfWeek Monday, Wednesday, Friday -WeeksInterval 2 -At "3:00 PM" |
    Add-TaskAction -Script { 
        Get-Process | Out-GridView 
        Start-Sleep -Seconds 100
    } |
    Register-ScheduledTask TestTask

New-task | 
    Add-TaskTrigger -In (New-TimeSpan -Seconds 30) |
    Add-TaskAction -Script { 
        Get-Process | Out-GridView 
        Start-Sleep -Seconds 100
    } |
    Register-ScheduledTask TestTask
David Brabant
  • 41,623
  • 16
  • 83
  • 111