I can not schedule task windows every day to execute each 1 minute. Power Shel 5

Welcome Forums General PowerShell Q&A I can not schedule task windows every day to execute each 1 minute. Power Shel 5

Viewing 3 reply threads
  • Author
    Posts
    • #209844
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member
      $A = New-ScheduledTaskAction -execute "powershell" -argument "-nologo -noprofile -noninteractive C:\Server\monitora_servidor.ps1"
      $hourly = (New-TimeSpan -Minutes 1)
      $dt= ([DateTime]::Now)
      $duration = $dt.AddYears(25) -$dt;
      $T = New-ScheduledTaskTrigger -Daily -RepetitionInterval $hourly -RepetitionDuration $duration
      Register-ScheduledTask -TaskName monitora_servidor_1 -Trigger $T -Action $A -description "SCRIPT_VERIFICA_SERVIDOR" -User "NT AUTHORITY\SYSTEM" -RunLevel 1
      Set-ScheduledTask monitora_servidor_1 -Trigger $T
    • #209847
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member
      # show this error message:
      
      New-ScheduledTaskTrigger: The parameter set cannot be resolved using the specified named parameters.
      No line: 5 characters: 6
      + $ T = New-ScheduledTaskTrigger -Daily -RepetitionInterval $ hourly -Re ...

    • #209928
      Participant
      Topics: 6
      Replies: 23
      Points: 103
      Helping Hand
      Rank: Participant

      Hi vpmaciel67
      Not sure as to what exactly you want to accomplish. Perhaps remove -Daily and execute them hourly? You could take a look at the new-scheduledtasktrigger examples and see if anything matches your goal.

    • #209988
      Participant
      Topics: 6
      Replies: 93
      Points: 427
      Helping Hand
      Rank: Contributor

      I agree with Emil, I think you have a conflict in using both Daily and setting a repeat interval of one minute.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.