Powershell v3 New-JobTrigger daily with repetition

This works for me:

Note - I know that the original question was related to New-JobTrigger The intent was to provide a possible solution that may be translatable to New-JobTrigger as well given the issue applies to both.

$A = New-ScheduledTaskAction -execute "powershell" -argument "-nologo -noprofile -noninteractive C:\MyScript.ps1"
$T = New-ScheduledTaskTrigger -Once -At 03:00AM 
Register-ScheduledTask -TaskName StartBasicServices_Local -Trigger $T -Action $A -description "MyScript" -User "NT AUTHORITY\SYSTEM" -RunLevel 1      
$T.RepetitionInterval = (New-TimeSpan -Minutes 5)
$T.RepetitionDuration = (New-TimeSpan -Days 1)
Set-ScheduledTask StartBasicServices_Local -Trigger $T

Tags:

Powershell