Here are some of the common PowerShell cmdlets for the Windows Task Scheduler with examples:
Get-ScheduledTask: This cmdlet is used to retrieve information about a specific task or all tasks in the Task Scheduler.
Example: Get-ScheduledTask -TaskName "Daily Backup"
Register-ScheduledTask: This cmdlet is used to create a new task in the Task Scheduler.
Example: $Action = New-ScheduledTaskAction -Execute "C:\Backup\backup.cmd"
$Trigger = New-ScheduledTaskTrigger -Daily -At "10:00 PM"
Register-ScheduledTask -TaskName "Daily Backup" -Action $Action -Trigger $Trigger
Set-ScheduledTask: This cmdlet is used to modify an existing task in the Task Scheduler.
Example: Set-ScheduledTask -TaskName "Daily Backup" -Trigger (New-ScheduledTaskTrigger -Daily -At "11:00 PM")
Unregister-ScheduledTask: This cmdlet is used to delete a task in the Task Scheduler.
Example: Unregister-ScheduledTask -TaskName "Daily Backup" -Confirm:$False
Start-ScheduledTask: This cmdlet is used to start a task in the Task Scheduler.
Example: Start-ScheduledTask -TaskName "Daily Backup"
Stop-ScheduledTask: This cmdlet is used to stop a running task in the Task Scheduler.
Example: Stop-ScheduledTask -TaskName "Daily Backup"
These are just a few of the many task-related cmdlets available in PowerShell. The above examples should give you a good idea of how to use these cmdlets to manage tasks in the Windows Task Scheduler.
No comments:
Post a Comment