0
0
PowerShellscripting~10 mins

Scheduled scripts with Task Scheduler in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new scheduled task action that runs a PowerShell script.

PowerShell
$action = New-ScheduledTaskAction -Execute [1] -Argument '-File C:\Scripts\Backup.ps1'
Drag options to blanks, or click blank then click option'
Anotepad.exe
Bcmd.exe
Cpowershell.exe
Dexplorer.exe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cmd.exe' instead of 'powershell.exe' will not run the PowerShell script.
Using 'notepad.exe' or 'explorer.exe' will open unrelated programs.
2fill in blank
medium

Complete the code to register a scheduled task named 'DailyBackup' with the action stored in $action.

PowerShell
Register-ScheduledTask -TaskName 'DailyBackup' -Trigger $trigger -[1] $action
Drag options to blanks, or click blank then click option'
ATrigger
BSettings
CPrincipal
DAction
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Trigger' instead of '-Action' will cause an error or unexpected behavior.
Using '-Principal' or '-Settings' does not assign the action.
3fill in blank
hard

Fix the error in the code to create a daily trigger at 3 AM.

PowerShell
$trigger = New-ScheduledTaskTrigger -Daily -At [1]
Drag options to blanks, or click blank then click option'
A"15:00"
B"03:00"
C"3 AM"
D"3:00 AM"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '3:00 AM' or '3 AM' causes format errors.
Using '15:00' sets the trigger to 3 PM, not 3 AM.
4fill in blank
hard

Fill both blanks to create a principal that runs the task as SYSTEM with highest privileges.

PowerShell
$principal = New-ScheduledTaskPrincipal -UserId [1] -RunLevel [2]
Drag options to blanks, or click blank then click option'
A"SYSTEM"
BRunLevel
CHighest
DInteractiveToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-InteractiveToken' instead of '-RunLevel Highest' will not set highest privileges.
Using other user IDs will not run the task as SYSTEM.
5fill in blank
hard

Fill all three blanks to create and register a scheduled task named 'NightlyCleanup' that runs a script at 11 PM daily with highest privileges.

PowerShell
$trigger = New-ScheduledTaskTrigger -Daily -At [1]
$principal = New-ScheduledTaskPrincipal -UserId [2] -RunLevel [3]
Register-ScheduledTask -TaskName 'NightlyCleanup' -Trigger $trigger -Action $action -Principal $principal
Drag options to blanks, or click blank then click option'
A"23:00"
B"SYSTEM"
CHighest
DInteractiveToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using '11:00 PM' instead of '23:00' causes errors.
Using '-InteractiveToken' instead of '-RunLevel Highest' does not set highest privileges.