0 Replies Latest reply on Oct 19, 2015 11:39 AM by NeoIsTaken

    Adding a failsafe to Scheduled Provisioning tasks


      I ran into an issue where a block of servers kicked off their scheduled task to patch and reboot.... needless to say people were not happy.


      To keep this from ever happening again I have changed the process to use provisioning, and added a powershell script to do a date/time check. If the date/time in not in range the script will exit with a value on 10100.

      The Powershell return code template is updated to reflect the exit code 10100 will display "Failsafe Triggered" and count as failed.




      Script code: (Example:  Only run on 3rd Monday between 7AM and 9AM)

      $Week = 3

      $Day = "Monday"

      [DateTime]$Start = "7:00 AM"

      [DateTime]$End = "9:00 AM"





      $Now = [DateTime]::now




      #Set to 1st day of current month

      $TargetDate = $Now.AddDays(-1*($Now.ToString("dd") - 1))




      #Align with $Day of week.

      while($TargetDate.ToString("dddd") -ne $Day){$TargetDate =$TargetDate.AddDays(1)}




      # Align with $Week

      $SyncDays = ($Week -1)*7

      $TargetDate =  $TargetDate.AddDays($SyncDays)




      #Process Failsafe

      IF(($TargetDate -ge $Start) -and ($TargetDate -le $End)){

      Exit 0


      Exit 10100