Bird
0
0

Which command correctly sets the action to run a PowerShell script located at C:\Tools\cleanup.ps1 using schtasks?

easy📝 Syntax Q3 of 15
PowerShell - Automation Patterns
Which command correctly sets the action to run a PowerShell script located at C:\Tools\cleanup.ps1 using schtasks?
Aschtasks /create /tn "CleanupTask" /tr "cleanup.ps1" /sc daily /st 22:00
Bschtasks /create /tn "CleanupTask" /tr "powershell.exe -File C:\Tools\cleanup.ps1" /sc daily /st 22:00
Cschtasks /create /tn "CleanupTask" /tr "powershell cleanup.ps1" /sc daily /st 22:00
Dschtasks /create /tn "CleanupTask" /tr "powershell.exe cleanup.ps1" /sc daily /st 22:00
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct executable and parameters

    PowerShell scripts require 'powershell.exe -File' followed by full script path.
  2. Step 2: Check syntax correctness

    schtasks /create /tn "CleanupTask" /tr "powershell.exe -File C:\Tools\cleanup.ps1" /sc daily /st 22:00 uses full path and correct flags; others omit '-File' or path.
  3. Final Answer:

    schtasks /create /tn "CleanupTask" /tr "powershell.exe -File C:\Tools\cleanup.ps1" /sc daily /st 22:00 -> Option B
  4. Quick Check:

    Use '-File' and full script path [OK]
Quick Trick: Use 'powershell.exe -File