Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Scheduled task management
📖 Scenario: You work in IT support. You need to manage scheduled tasks on a Windows computer to automate daily reports.
🎯 Goal: Build a PowerShell script that creates a scheduled task to run a report script daily, checks the task status, and displays the task details.
📋 What You'll Learn
Create a scheduled task action to run a script
Set a daily trigger for the scheduled task
Register the scheduled task with a specific name
Query the scheduled task status
Display the scheduled task details
💡 Why This Matters
🌍 Real World
Automating daily reports or maintenance tasks on Windows computers saves time and reduces manual work.
💼 Career
IT professionals and system administrators often create and manage scheduled tasks to automate routine jobs.
Progress0 / 4 steps
1
Create the scheduled task action
Create a variable called $action that defines a scheduled task action to run the program powershell.exe with the argument -File C:\Scripts\DailyReport.ps1.
PowerShell
Hint
Use New-ScheduledTaskAction with -Execute and -Argument parameters.
2
Create a daily trigger for the task
Create a variable called $trigger that sets a daily scheduled task trigger to start at 8:00 AM.
PowerShell
Hint
Use New-ScheduledTaskTrigger with -Daily and -At 8am.
3
Register the scheduled task
Use Register-ScheduledTask to create a scheduled task named DailyReportTask using the variables $action and $trigger. Store the registered task in a variable called $task.
PowerShell
Hint
Use Register-ScheduledTask with -TaskName, -Action, and -Trigger.
4
Display the scheduled task details
Use Get-ScheduledTask to get the task named DailyReportTask and then use Get-ScheduledTaskInfo to get its status. Print both the task and its status.
PowerShell
Hint
Use Get-ScheduledTask and Get-ScheduledTaskInfo with -TaskName 'DailyReportTask'. Use Write-Output to print.
Practice
(1/5)
1. What is the main purpose of a scheduled task in PowerShell?
easy
A. To monitor system performance continuously
B. To manually execute scripts only when needed
C. To run scripts or programs automatically at specific times
D. To edit files in the system
Solution
Step 1: Understand scheduled task purpose
Scheduled tasks are designed to automate running scripts or programs without manual intervention.
Step 2: Compare options
Only To run scripts or programs automatically at specific times describes automatic execution at set times, which matches scheduled tasks.
Final Answer:
To run scripts or programs automatically at specific times -> Option C
Quick Check:
Scheduled tasks automate running scripts [OK]
Hint: Scheduled tasks run automatically on a schedule [OK]
Common Mistakes:
Confusing scheduled tasks with manual script runs
Thinking scheduled tasks monitor system performance
Assuming scheduled tasks edit files automatically
2. Which PowerShell cmdlet is used to create a new scheduled task trigger?
easy
A. New-ScheduledTaskTrigger
B. New-ScheduledTaskAction
C. Register-ScheduledTask
D. Get-ScheduledTask
Solution
Step 1: Identify cmdlet for trigger creation
The cmdlet New-ScheduledTaskTrigger is specifically used to define when a scheduled task should run.
Step 2: Differentiate from other cmdlets
New-ScheduledTaskAction defines what runs, Register-ScheduledTask registers the task, and Get-ScheduledTask retrieves tasks.