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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.