Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The scheduled task action must execute 'powershell.exe' to run a PowerShell script.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The parameter to specify the action for the scheduled task is '-Action'.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The '-At' parameter requires time in 'HH:mm' 24-hour format, so '03:00' is correct for 3 AM.
4fill in blank
hardFill 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'
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.
✗ Incorrect
The UserId must be 'SYSTEM' and the RunLevel must be 'Highest' to run with highest privileges.
5fill in blank
hardFill 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'
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.
✗ Incorrect
The trigger time is '23:00' for 11 PM, the user is 'SYSTEM', and 'Highest' for RunLevel sets highest privileges.