Monthly Clustered Scheduled Task – Trigger

Welcome Forums General PowerShell Q&A Monthly Clustered Scheduled Task – Trigger

Viewing 4 reply threads
  • Author
    Posts
    • #247041
      Participant
      Topics: 1
      Replies: 2
      Points: 0
      Rank: Member

      Hi Everyone,

      I am looking for some help in scripting the Monthly trigger for Clustered Scheduled task, this has to be configured through Powershell and GUI does not work. For Clustered Scheduled task it has only daily and Weekly but not direct Monthly trigger, need to have a workaround to have this done.

      if ((Get-Date).day -eq 01) <span class="pun">{</span> $action<span class="pun">=</span> <span class="typ">New</span><span class="pun">-</span><span class="typ">ScheduledTaskAction</span> <span class="pun">-</span><span class="typ">Execute</span> <span class="str">"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"</span> <span class="pun">-</span><span class="typ">Argument</span> <span class="str">"E:\SCRIPTS\TaskScheduler\Test123.ps1"</span> <span class="pun">}</span> <span class="typ">Register</span><span class="pun">-</span><span class="typ">ClusteredScheduledTask</span> <span class="pun"></span><span class="typ">Cluster</span> <span class="str">"Taskserver01.contoso.com"</span> <span class="pun"></span><span class="typ">TaskType</span> <span class="typ">AnyNode</span> <span class="pun"></span><span class="typ">Action</span> $action <span class="pun"></span><span class="typ">Trigger</span> $trigger <span class="pun"></span><span class="typ">TaskName</span> <span class="typ">Test123</span> [/crayon]
    • #247194
      Participant
      Topics: 5
      Replies: 328
      Points: 522
      Helping Hand
      Rank: Major Contributor

      You can use the following trigger to get close to a month or Schtasks.exe for a more accurate monthly task.

    • #247241
      Participant
      Topics: 1
      Replies: 2
      Points: 0
      Rank: Member

      Thanks for the reply. As you said it is close to a month, not sure we can use Schtasks.exe for Clustered Scheduled Task

    • #247288
      Participant
      Topics: 7
      Replies: 121
      Points: 587
      Helping Hand
      Rank: Major Contributor

      Just thinking out loud here, not able to test. Have you tried creating a task using the monthly trigger, export that to XML, then try importing that using the -Xml option to Register-ClusteredScheduledTask ??

    • #247429
      Participant
      Topics: 1
      Replies: 2
      Points: 0
      Rank: Member

      I have also tried the XML import,  for regular Scheduled task it is working but not for the Clustered Scheduled task. Finally found a workaround. I have applied the ‘if’ condition in the script from the action trigger and its working.

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