PowerShell scheduled job trigger

Welcome Forums General PowerShell Q&A PowerShell scheduled job trigger

Viewing 3 reply threads
  • Author
    Posts
    • #239447
      Participant
      Topics: 39
      Replies: 46
      Points: 88
      Rank: Member

      Hi, I have created PS scheduled job (v 5.1) that executes script producing HTML report of expiring certificates. I would like to run this script on every 1st and 15th of the month at 5:00 am AZ time. Is this doable? When I try to accomplish this directly from task scheduler GUI job does not run on given schedule with Get-ScheduledJob complaining about unknown trigger type:

      Get-ScheduledJob : An unknown trigger type was returned from Task Scheduler for scheduled job definition Expiring Certificates Report with trigger ID

      What can be done here?

      Thx in advance.

    • #239459
      Participant
      Topics: 5
      Replies: 2372
      Points: 6,005
      Helping Hand
      Rank: Community MVP

      When I try to accomplish this directly from task scheduler GUI job does not run on given schedule …

      So there might be another issue with your task. I usually use the cmldets for scheduled tasks (not jobs):

      Get-Command -Noun *scheduledtask*
    • #239495
      Participant
      Topics: 39
      Replies: 46
      Points: 88
      Rank: Member

      With other PS scheduled jobs I do not have problems – Get-ScheduledJob returns all PS scheduled jobs. Here problem probably lies in the fact PS scheduled jobs do not support monthly schedules (in GUI I put trigger as monthly on 1st and 15th day) – exactly what I need.

    • #239546
      Participant
      Topics: 3
      Replies: 417
      Points: 1,462
      Helping Hand
      Rank: Community Hero

      ScheduledJobs are not a replacement for scheduled tasks. As you’ve discovered, there is no monthly [Microsoft.Powershell.ScheduledJob.TriggerFrequency]. If you want that granular control, and scheduledjob doesn’t do it, then you should use scheduledtask. You can have the scheduled task run a script with the same exact job, you can even output it to XML to the default location if you prefer. You should not try to edit the job in the GUI. Some good info you may have seen already, but in case you haven’t and for others.

      https://4sysops.com/archives/create-powershell-scheduled-jobs/

      https://powershell.org/forums/topic/new-scheduled-job/

      https://docs.microsoft.com/en-us/powershell/module/psscheduledjob/about/about_scheduled_jobs_advanced?view=powershell-5.1

      https://4sysops.com/archives/managing-powershell-scheduled-jobs/

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