0
0
PowerShellscripting~20 mins

Scheduled scripts with Task Scheduler in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Task Scheduler Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this PowerShell command to list scheduled tasks?
You run this command in PowerShell to list all scheduled tasks on your system:
Get-ScheduledTask | Select-Object -First 1 | Format-List

What kind of output should you expect?
PowerShell
Get-ScheduledTask | Select-Object -First 1 | Format-List
AA detailed list of properties of the first scheduled task, including TaskName, State, and Actions.
BA simple list of task names only, without any other details.
CA table showing all scheduled tasks with their next run times.
DAn error saying 'Get-ScheduledTask' is not recognized as a cmdlet.
Attempts:
2 left
💡 Hint
Think about what Format-List does and what Select-Object -First 1 returns.
📝 Syntax
intermediate
2:00remaining
Which PowerShell command correctly creates a scheduled task to run a script daily at 7 AM?
You want to create a scheduled task that runs 'C:\Scripts\backup.ps1' every day at 7 AM. Which command is correct?
ARegister-ScheduledTask -TaskName "DailyBackup" -Trigger (New-ScheduledTaskTrigger -Daily -At 7am) -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\backup.ps1")
BNew-ScheduledTask -TaskName "DailyBackup" -Trigger (New-ScheduledTaskTrigger -Daily -At 7am) -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\backup.ps1")
CRegister-ScheduledTask -Name "DailyBackup" -Trigger (New-ScheduledTaskTrigger -Daily -At 7am) -Action (New-ScheduledTaskAction -Execute "powershell.exe" -File "C:\Scripts\backup.ps1")
DNew-ScheduledTask -TaskName "DailyBackup" -Trigger (New-ScheduledTaskTrigger -Daily -At "7:00") -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\backup.ps1")
Attempts:
2 left
💡 Hint
Register-ScheduledTask is used to create the task in Task Scheduler. Check parameter names carefully.
🔧 Debug
advanced
2:00remaining
Why does this scheduled task fail to run the script?
You created a scheduled task with this action:
New-ScheduledTaskAction -Execute "powershell.exe" -Argument "C:\Scripts\cleanup.ps1"

But the script never runs. What is the problem?
AThe scheduled task must run as administrator to execute scripts.
BThe script path must be enclosed in single quotes inside -Argument.
CThe -Execute parameter should be 'pwsh.exe' instead of 'powershell.exe'.
DThe -Argument parameter is missing the '-File' flag before the script path.
Attempts:
2 left
💡 Hint
Check how PowerShell expects script files to be passed as arguments.
🚀 Application
advanced
2:30remaining
How to export and import a scheduled task using PowerShell?
You want to move a scheduled task named 'WeeklyReport' from one computer to another. Which sequence of commands correctly exports and imports the task?
AExport-ScheduledTask -TaskName "WeeklyReport" -Path "C:\Temp\WeeklyReport.xml"; Register-ScheduledTask -Xml (Get-Content "C:\Temp\WeeklyReport.xml" | Out-String) -TaskName "WeeklyReport"
BExport-ScheduledTask -TaskName "WeeklyReport" -File "C:\Temp\WeeklyReport.xml"; Register-ScheduledTask -Xml (Get-Content "C:\Temp\WeeklyReport.xml") -TaskName "WeeklyReport"
CExport-ScheduledTask -TaskName "WeeklyReport" -Path "C:\Temp\WeeklyReport.xml"; Register-ScheduledTask -Xml (Get-Content "C:\Temp\WeeklyReport.xml" -Raw) -TaskName "WeeklyReport"
Dschtasks /Query /TN "WeeklyReport" /XML > "C:\Temp\WeeklyReport.xml"; schtasks /Create /TN "WeeklyReport" /XML "C:\Temp\WeeklyReport.xml"
Attempts:
2 left
💡 Hint
Get-Content with -Raw reads the entire XML as a single string needed for -Xml parameter.
🧠 Conceptual
expert
1:30remaining
What is the effect of setting the 'RunLevel' property to 'Highest' in a scheduled task?
In Task Scheduler, you set the 'RunLevel' property of a task to 'Highest'. What does this do?
AThe task runs only when the user is logged in with highest privileges.
BThe task runs with administrator privileges, prompting for elevation if needed.
CThe task runs with the highest CPU priority to finish faster.
DThe task runs with the highest memory allocation allowed by the system.
Attempts:
2 left
💡 Hint
Think about Windows User Account Control and task permissions.