Powershell: Scheduled Task with Daily Trigger and Repetition Interval

While the PowerShell interface for scheduled task triggers is limited, it turns out if you set the RepetitionDuration to [System.TimeSpan]::MaxValue, it results in a duration of “Indefinitely”.

$trigger = New-ScheduledTaskTrigger `
    -Once `
    -At (Get-Date) `
    -RepetitionInterval (New-TimeSpan -Minutes 5) `
    -RepetitionDuration ([System.TimeSpan]::MaxValue)

Tested on Windows Server 2012 R2 (PowerShell 4.0)

Leave a Comment