azure-powershell
azure-powershell copied to clipboard
New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure requries a -ProcessServer of type Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServer, but the FabricObject only has Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails
Description
Based off this article: https://docs.microsoft.com/en-us/azure/site-recovery/vmware-azure-disaster-recovery-powershell
I should be able to retrieve an ASRProcessServer object from the $ASRFabricObject.FabricSpecificDetails.ProcessServers.
>$ASRResourceGroup = "MyRG"
>$ASRVaultName = "MyVault"
>$ASRVaultObject = Get-AzRecoveryServicesVault -ResourceGroupName $ASRResourceGroup -Name $ASRVaultName
>$ASRContext = Set-AzRecoveryServicesAsrVaultContext -Vault $ASRVaultObject
>$FabricName = "$($ASRVaultName)-vmwarefabric"
>$ASRFabricObject = Get-AzRecoveryServicesAsrFabric -Name $FabricName
>$ASRFabricObject
Name : prd-usce-asr-vlt-vmwarefabric
FriendlyName : prd-usce-asr-vlt-vmwarefabric
ID : /Subscriptions/12345-1234-1234/resourceGroups/MyRG/providers/Microsoft.RecoveryServices/vaults/MyVault/replicationFabrics/MyVault-vmwarefabric
Type : Microsoft.RecoveryServices/vaults/replicationFabrics
FabricType : InMageRcm
SiteIdentifier : cc67019a-72de-5ddc-b9cc-80316fd258e1
FabricSpecificDetails : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRInMageRcmFabricSpecificDetails
> $ASRFabricObject.FabricSpecificDetails.ProcessServers.GetType().FullName
System.Collections.Generic.List`1[[Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails, Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.SiteRecovery, Version=5.4.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
. . .
>$Job_EnableReplication = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure `
-ProtectableItem $VMObject `
-Size $DestVMSize `
-Name (New-Guid).Guid `
-ProtectionContainerMapping $ASRProtectionContainerMap `
-LogStorageAccountId $StorageAccountObject.Id `
-ProcessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] `
-RecoveryResourceGroupId $DestRGObject.ResourceId `
-RecoveryAzureNetworkId $$DestVnetObject.Id `
-RecoveryAzureSubnetName $DestSubnet `
-TestNetworkId $DestBubblevNetObject.id `
-TestSubnetName $DestBubbleSubnet `
-CredentialsToAccessVm $VMCredAccount
New-AzRecoveryServicesAsrReplicationProtectedItem:
Line |
7 | … ocessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot bind parameter 'ProcessServer'. Cannot convert the "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" value of type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" to type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServer".
There doesn't seem to be
Issue script & Debug output
> $DebugPreference = 'Continue'
> New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure `
>> -ProtectableItem $VMObject `
>> -Size $DestVMSize `
>> -Name (New-Guid).Guid `
>> -ProtectionContainerMapping $ASRProtectionContainerMap `
>> -LogStorageAccountId $StorageAccountObject.Id `
>> -ProcessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] `
>> -RecoveryResourceGroupId $DestRGObject.ResourceId `
>> -RecoveryAzureNetworkId $$DestVnetObject.Id `
>> -RecoveryAzureSubnetName $DestSubnet `
>> -TestNetworkId $DestBubblevNetObject.id `
>> -TestSubnetName $DestBubbleSubnet `
>> -CredentialsToAccessVm $VMCredAccount
New-AzRecoveryServicesAsrReplicationProtectedItem:
Line |
7 | … ocessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot bind parameter 'ProcessServer'. Cannot convert the "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" value of type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" to type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServer".
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
get-module az*
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.9.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 4.19.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAddressPool, Add-AzApplicationGatewayBackendHttpSetting, A…
Script 5.4.1 Az.RecoveryServices {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Backup-AzRecoveryServicesBackupItem, Copy-AzRecoveryServicesVault, Disable-AzRecovery…
Script 6.1.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
Script 4.8.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccountNetworkRule, Close-AzStorageFileHandle…}
Error output
> Resolve-AzError
4:09:23 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
4:09:23 PM - using account id '[email protected]'...
4:09:23 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release. Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: 19
Message : Cannot bind parameter 'ProcessServer'. Cannot convert the "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" value of type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" to type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServer".
StackTrace : at System.Management.Automation.ParameterBinderBase.CoerceTypeAsNeeded(CommandParameterInternal argument, String parameterName, Type toType, ParameterCollectionTypeInformation collectionTypeInfo, Object currentValue)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.ParameterBindingException
InvocationInfo : {New-AzRecoveryServicesAsrReplicationProtectedItem}
Line : -ProcessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] `
Position : At line:7 char:28
+ … ocessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 19
Message : Cannot convert the "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" value of type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServerDetails" to type "Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRProcessServer".
StackTrace : at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
at System.Management.Automation.LanguagePrimitives.ConversionData`1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable)
at System.Management.Automation.ParameterBinderBase.CoerceTypeAsNeeded(CommandParameterInternal argument, String parameterName, Type toType, ParameterCollectionTypeInformation collectionTypeInfo, Object currentValue)
Exception : System.Management.Automation.PSInvalidCastException
InvocationInfo : {New-AzRecoveryServicesAsrReplicationProtectedItem}
Line : -ProcessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] `
Position : At line:7 char:28
+ … ocessServer $ASRFabricObject.FabricSpecificDetails.ProcessServers[0] …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 19
Thank you for your feedback. This has been routed to the support team for assistance.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Sharmistha-Rai.