I need ScheduledTask executing every day. Hou to do It ? What I have to change ?

Welcome Forums General PowerShell Q&A I need ScheduledTask executing every day. Hou to do It ? What I have to change ?

Viewing 1 reply thread
  • Author
    Posts
    • #204882
      Participant
      Topics: 8
      Replies: 8
      Points: 93
      Rank: Member
      $A = New-ScheduledTaskAction -execute "powershell" -argument "-nologo -noprofile -noninteractive C:\Server\monitora_disco.ps1"
      $hourly = (New-TimeSpan -Minutes 3)
      $days = (New-TimeSpan -Days 3)
      $T = New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval $hourly -RepetitionDuration $days
      Register-ScheduledTask -TaskName monitora_disco_2 -Trigger $T -Action $A -description "SCRIPT_VERIFICA_SERVIDOR" -User "NT AUTHORITY\SYSTEM" -RunLevel 1
      Set-ScheduledTask monitora_disco_2 -Trigger $T
      
      • This topic was modified 3 months ago by vpmaciel67.
      • This topic was modified 3 months ago by kvprasoon. Reason: code formatting
    • #204978
      Senior Moderator
      Topics: 8
      Replies: 1215
      Points: 4,334
      Helping Hand
      Rank: Community Hero

      Just use -Daily switch of New-ScheduledTaskTrigger cmdlet.

      Get-Help New-ScheduledTaskTrigger -ShowWindow
      
Viewing 1 reply thread
  • The topic ‘I need ScheduledTask executing every day. Hou to do It ? What I have to change ?’ is closed to new replies.