how do powershell scheduled task -repetitionduration indefinitely ?

Welcome Forums General PowerShell Q&A how do powershell scheduled task -repetitionduration indefinitely ?

Viewing 4 reply threads
  • Author
    Posts
    • #205128
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member

      $A = New-ScheduledTaskAction -execute "powershell" -argument "-nologo -noprofile -noninteractive C:\Server\Servidor.ps1"
      $hourly = (New-TimeSpan -Minutes 5)
      $dt= ([DateTime]::Now)
      $duration = $dt.AddYears(30) -$dt;
      $T = New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval $hourly -RepetitionDuration $duration
      Register-ScheduledTask -TaskName monitora_email_2 -Trigger $T -Action $A -description "SCRIPT_VERIFICA_SERVIDOR" -User "NT AUTHORITY\SYSTEM" -RunLevel 1
      Set-ScheduledTask monitora_email_2 -Trigger $T

    • #205140
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      Could you please explain what you want to do?

    • #205149
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member

      Could you please explain what you want to do?

      I need you to run this event every 5 minutes with no time to finish, every day. Not just for 30 years, but forever. If your computer turns off and on, the task should be working.
      
      
    • #205152
      Participant
      Topics: 23
      Replies: 48
      Points: 285
      Helping Hand
      Rank: Contributor

      If you do not specify repetitionduration parameter, it will set to indefinitely. ☺️

    • #205158
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member

      If you do not specify repetitionduration parameter, it will set to indefinitely. ☺️

      It works. Thank you.

Viewing 4 reply threads
  • The topic ‘how do powershell scheduled task -repetitionduration indefinitely ?’ is closed to new replies.