Bird
0
0

This script produces an error:

medium📝 Debug Q7 of 15
PowerShell - System Administration
This script produces an error:
$action = New-ScheduledTaskAction -Execute 'notepad.exe'
Register-ScheduledTask -TaskName 'OpenNotepad' -Trigger $trigger -Action $action

What is missing to fix the error?
AUse Start-ScheduledTask instead of Register-ScheduledTask
BSpecify the user account with -User parameter
CAdd the -Force parameter to Register-ScheduledTask
DDefine the $trigger variable before using it
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the script

    The script uses $trigger but it is not defined anywhere.
  2. Step 2: Understand Register-ScheduledTask requirements

    Both -Trigger and -Action parameters are mandatory and must be valid objects.
  3. Final Answer:

    Define the $trigger variable before using it -> Option D
  4. Quick Check:

    Verify $trigger is initialized with New-ScheduledTaskTrigger [OK]
Quick Trick: Always define triggers before registering tasks [OK]
Common Mistakes:
  • Assuming user account is mandatory without context
  • Using -Force without cause
  • Confusing Register-ScheduledTask with Start-ScheduledTask

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes