Using PowerShell 7.3.1, so can't use Register-ScheduledJob
. without having to directly modify scheduled task XML files, since they are stored in 3 different places, how can I create a scheduled task in Windows that runs every x hours or x minutes.
I've done this in GUI
and I want to do something like that in PowerShell.
I've checked out this similar question, but it's incomplete for my situation.
Reading New-ScheduledTaskTrigger
info, can't seem to find a parameter for each of them.
this is all I could figure out
$trigger = New-ScheduledTaskTrigger -RepetitionInterval "PT5M"
another idea, if it's actually impossible to do what I want with native PowerShell, what if I create my task with PowerShell and a placeholder trigger like at startup
, then use schtasks.exe
to configure the trigger according to the screenshot I uploaded?
if that's doable, what are the command(s) for using schtasks.exe
to modify the trigger like in the screenshot?