I'm trying to add a Powershell script to task scheduler to run on a regular basis.
Import-Module ScheduledTasks
$scriptFilePath = "C:\hello-there.ps1"
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File $scriptFilePath -Noninteractive"
$repetitionDuration = New-TimeSpan -End (Get-Date -Year 2030 -Month 4)
$repetitionInterval = New-TimeSpan -Minute 15
$trigger = New-ScheduledTaskTrigger -RepetitionDuration $repetitionDuration -RepetitionInterval $repetitionInterval
Register-ScheduledTask -TaskName "custom-task" -Description "Does something important" -Trigger $trigger -Action $action
It executes until New-ScheduledTaskTrigger
line, then asks me for user input? "Supply values for the following parameters"
What am I doing wrong?