azureazure-automationazure-scheduler

Retrieval of Azure Runbook schedules list having a particular schedule triggered on a weekly basis generates an error


I've recently created a runbook schedule which is executed periodically - every 1 week on Monday without expiry date. The creation of schedule was flawless. However when i want to retrieve a list of all runbook schedules using the powershell cmdlet

Get-AzureAutomationSchedule -AutomationAccountName $automationAccountName 
i get an error message:
Get-AzureAutomationSchedule : Nie można znaleźć żądanej wartości 'Week'. (The value 'Week' could not be found)
+  Get-AzureAutomationSchedule -AutomationAccountName $automationAccoun ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureAutomationSchedule], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationSchedule

When i remove this particular schedule the full list of available schedules appears.

I've got also schedules than run on hourly/daily basis and they do not generate such problems.

Any help would be much appreciated.

After running the command Get-AzureRmAutomationSchedule -Name name_of_the_failing_schedule as suggested by @4c74356b41 i get the same error message.

Below u can see the body of http response after running the cmdlet in debug mode

{
  "id": "/subscriptions/XXXXXXXXX",
  "name": "orphaned objects",
  "properties": {
    "description": "",
    "startTime": "2016-11-28T09:00:00+01:00",
    "startTimeOffsetMinutes": 0.0,
    "expiryTime": "9999-12-31T23:59:59.9999999+01:00",
    "expiryTimeOffsetMinutes": 0.0,
    "isEnabled": true,
    "nextRun": "2016-11-28T09:00:00+01:00",
    "nextRunOffsetMinutes": 0.0,
    "interval": 1,
    "frequency": "Week",
    "creationTime": "2016-11-22T10:41:49.433+01:00",
    "lastModifiedTime": "2016-11-22T10:41:49.433+01:00",
    "timeZone": "UTC",
    "advancedSchedule": {
      "monthDays": null,
      "monthlyOccurrences": null,
      "weekDays": [
        "Monday"
      ]
    }
  }

Solution

  • I get the same error on older versions of the AzureRM.Automation PowerShell module:

    PS C:\Users\Joe> Get-AzureRmAutomationSchedule -Name Every1WeekOnMonday -AutomationAccountName DemoAccount -ResourceGroupName DemoGroup
    Get-AzureRmAutomationSchedule : Requested value 'Week' was not found.
    At line:1 char:1
    + Get-AzureRmAutomationSchedule -Name Every1WeekOnMonday -AutomationAcc ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : CloseError: (:) [Get-AzureRmAutomationSchedule], ArgumentException
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationSchedule
    
    
    PS C:\Users\Joe> Get-Module -Name AzureRM.Automation
    
    ModuleType Version    Name                                ExportedCommands                                                       
    ---------- -------    ----                                ----------------                                                       
    Manifest   1.0.4      AzureRM.Automation                  {Export-AzureRmAutomationDscConfiguration, Export-AzureRmAutomationD...
    

    Upgrading to the latest version of the AzureRM PowerShell cmdlets fixes this:

    PS C:\Users\Joe> Get-AzureRmAutomationSchedule -Name Every1WeekOnMonday -AutomationAccountName DemoAccount -ResourceGroupName DemoGroup
    
    
    StartTime              : 11/22/2016 6:44:00 PM -08:00
    ExpiryTime             : 12/31/9999 3:59:00 PM -08:00
    IsEnabled              : True
    NextRun                : 11/28/2016 6:44:00 PM -08:00
    Interval               : 1
    Frequency              : Week
    MonthlyScheduleOptions : Microsoft.Azure.Commands.Automation.Model.MonthlyScheduleOptions
    WeeklyScheduleOptions  : Microsoft.Azure.Commands.Automation.Model.WeeklyScheduleOptions
    TimeZone               : America/Los_Angeles
    ResourceGroupName      : DemoGroup
    AutomationAccountName  : DemoAccount
    Name                   : Every1WeekOnMonday
    CreationTime           : 11/22/2016 6:15:08 PM -08:00
    LastModifiedTime       : 11/22/2016 6:15:08 PM -08:00
    Description            : 
    
    
    
    
    PS C:\Users\Joe>  Get-Module -Name AzureRM.Automation
    
    ModuleType Version    Name                                ExportedCommands                                                       
    ---------- -------    ----                                ----------------                                                       
    Manifest   2.3.0      AzureRM.Automation                  {Export-AzureRmAutomationDscConfiguration, Export-AzureRmAutomationD...
    

    So you can resolve this issue by upgrading to the latest version of the AzureRM PowerShell cmdlets.