I am unable to update the value of the ScheduleRunTimes property on a Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.DailySchedule type object. The Property type is shown to be a DateTime object, when supplying a new DateTime object a SetValueInvocationException is thrown indicating a "Invalid cast from 'System.DateTime' to 'System.Collections.Generic.List`1[[System.DateTime"
Issue script & Debug output
PS> $DebugPreference='Continue'
PS> $schPol = Get-AzRecoveryServicesBackupSchedulePolicyObject -PolicySubType "Enhanced" -WorkloadType "AzureVM" -ScheduleRunFrequency "Daily" -ErrorAction Stop
DEBUG: 5:16:36 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 5:16:36 PM - GetAzureRmRecoveryServicesBackupSchedulePolicyObject begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 5:16:36 PM - using account id 'MSI@50342'...
DEBUG: 5:16:36 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: Inside Restore. Going to create ResourceClient.
DEBUG: [Common.Authentication]: Authenticating using Account: 'MSI@50342', environment: 'AzureCloud', tenant: '65911ec9-c247-4e7f-b3e5-239b468be687'
DEBUG: 5:16:36 PM - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 5:16:36 PM - [ManagedServiceIdentityAuthenticator] Calling ManagedIdentityCredential.GetTokenAsync - TenantId:'65911ec9-c247-4e7f-b3e5-239b468be687', Scopes:'https://management.core.windows.net/', UserId:''
DEBUG: ManagedIdentityCredential.GetToken invoked. Scopes: [ https://management.core.windows.net/ ] ParentRequestId:
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] MSAL MSAL.CoreCLR with assembly version '4.61.3.0'. CorrelationId(d800e9a2-9edd-4486-a590-d2511e99d704)
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] === AcquireTokenForClientParameters ===
SendX5C: False
ForceRefresh: False
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net/
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenForClient
IsConfidentialClient - True
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - d800e9a2-9edd-4486-a590-d2511e99d704
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] === Token Acquisition (ClientCredentialRequest) started:
Scopes: https://management.core.windows.net/
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] [Instance Discovery] Skipping Instance discovery because it is disabled.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] [ClientCredentialRequest] Acquiring a token from the token provider.
DEBUG: Request [8bd4735f-f16a-49fd-84fa-e7e0c3c599cf] POST http://localhost:50342/oauth2/token
Content-Type:application/x-www-form-urlencoded
Metadata:REDACTED
x-ms-client-request-id:8bd4735f-f16a-49fd-84fa-e7e0c3c599cf
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.12.0 (.NET 8.0.8; CBL-Mariner/Linux)
client assembly: Azure.Identity
DEBUG: Response [8bd4735f-f16a-49fd-84fa-e7e0c3c599cf] 200 OK (00.0s)
X-Powered-By:REDACTED
ETag:W/"b91-/GrODResVrafDoQeweEO9Bghm9I"
Date:Tue, 12 Nov 2024 17:16:36 GMT
Connection:keep-alive
Keep-Alive:REDACTED
Content-Type:application/json; charset=utf-8
Content-Length:2961
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Checking client info returned from the server..
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Saving token response to cache..
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] [SaveTokenResponseAsync] ID Token not present in response.
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Cannot determine home account ID - or id token or no client info and no subject
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] [SaveTokenResponseAsync] Saving AT in cache and removing overlapping ATs...
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Looking for scopes for the authority in the cache which intersect with https://management.core.windows.net/
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Intersecting scope entries count - 0
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] AT expiration time: 11/12/2024 5:52:59 PM +00:00, scopes: https://management.core.windows.net/. source: IdentityProvider
DEBUG: False MSAL 4.61.3.0 MSAL.CoreCLR .NET 8.0.8 Linux [2024-11-12 17:16:36Z - d800e9a2-9edd-4486-a590-d2511e99d704] Fetched access token from host login.microsoftonline.com.
DEBUG: ManagedIdentityCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net/ ] ParentRequestId: ExpiresOn: 2024-11-12T17:52:59.0144632+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '65911ec9-c247-4e7f-b3e5-239b468be687', UserId: 'MSI@50342'
DEBUG: Client Created successfully
DEBUG: 5:16:36 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 5:16:36 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:16:36 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.RecoveryServices:7.2.0; CommandName: Get-AzRecoveryServicesBackupSchedulePolicyObject; PSVersion: 7.4.5; IsSuccess: True; Duration: 00:00:00.0162653; SanitizeDuration: 00:00:00.0001907
DEBUG: 5:16:36 PM - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 5:16:36 PM - GetAzureRmRecoveryServicesBackupSchedulePolicyObject end processing.
PS> $time = [System.DateTime]::SpecifyKind((Get-Date).Date.AddHours(5), [System.DateTimeKind]::Utc)
PS> $time
Tuesday, November 12, 2024 5:00:00 AM
PS> $schPol.DailySchedule.ScheduleRunTimes
Tuesday, November 12, 2024 2:00:00 PM
PS> $schPol.DailySchedule.ScheduleRunTimes = $time
SetValueInvocationException: Exception setting "ScheduleRunTimes": "Cannot convert value "11/12/2024 5:00:00 AM" to type "System.Collections.Generic.List`1[System.DateTime]". Error: "Invalid cast from 'System.DateTime' to 'System.Collections.Generic.List`1[[System.DateTime, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'.""
PS> $schPol.DailySchedule.ScheduleRunTimes | gm
TypeName: System.DateTime
PS> $time | gm
TypeName: System.DateTime
Environment data
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS CBL-Mariner/Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Description
Hello,
I am unable to update the value of the ScheduleRunTimes property on a Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.DailySchedule type object. The Property type is shown to be a DateTime object, when supplying a new DateTime object a SetValueInvocationException is thrown indicating a "Invalid cast from 'System.DateTime' to 'System.Collections.Generic.List`1[[System.DateTime"
Issue script & Debug output
Environment data
Module versions
Error output