register-schedulejob not running

This topic contains 1 reply, has 2 voices, and was last updated by  Darwin Reiswig 1 month ago.

  • Author
    Posts
  • #99259

    PowershellNoob
    Participant

    Hello there everyone,
    I tried running the following script as a scheduled job, but for some reason it does not run as a scheduled job. The script works, but I believe that I may be doing something incorrectly with the register-schedulejob comdlet. Anyone might providing input? Thank you very much. this has been a hit or miss for me and I am near certain that I am doing something incorrectly. Thank you again for taking your time to help!

    receive-job * -keep returns nothing.

    
    Import-Module activedirectory
    $Trigger = @()
    $Trigger += New-JobTrigger -Daily -at "1:00 PM"
    $Trigger += New-JobTrigger -Daily -at "5:00 PM"
    $Option = New-ScheduledJobOption -RequireNetwork -WakeToRun
    $Credentials = Get-Credential
     Register-ScheduledJob -Name "Provision-Computers" -ScriptBlock { 
    
    } -Trigger $Trigger -ScheduledJobOption $Option -MaxResultCount '2' -Credential $Credentials -RunNow
  • #99636

    Darwin Reiswig
    Participant

    Do you see the job if you run Get-ScheduledJob?

    I haven't worked with Scheduled Jobs much, but Scripting Guy wrote an introduction to Scheduled Jobs that might be helpful:

You must be logged in to reply to this topic.