Get-AzRecoveryServicesAsrProtectableItem doesn't show same results as portal

Christopher Lewis 21 Reputation points
2022-08-03T16:12:12.903+00:00

I'm trying to automate ASR and I can see a VM in the portal, however I'm not seeing it in the Get-AzRecoveryServicesAsrProtectableItem cmdlet.

code:

$ResourceGroup = 'MyRG'  
$ASRVaultName = 'MyVault'  
  
$ASRVaultObject = Get-AzRecoveryServicesVault -ResourceGroupName $ResourceGroup -Name $ASRVaultName  
  
#Set our ASR context  
Set-AzRecoveryServicesAsrVaultContext -Vault $ASRVaultObject     
#Get-AzRecoveryServicesAsrVaultContext  
  
#Get our vmware fabric  
$FabricName = "$($ASRVaultName)-vmwarefabric"  
$ASRFabricObject = Get-AzRecoveryServicesAsrFabric -Name $FabricName   
  
#Protection Container  
$ASRProtectionContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $ASRFabricObject  
$ASRProtectionContainerMapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $ASRProtectionContainer  
  
  
#Get protectable items by Center  
$AllServers = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ASRProtectionContainer -SiteId $ASRFabricObject.FabricSpecificDetails.VmwareSiteId  
  
$MyServer = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ASRProtectionContainer -SiteId $ASRFabricObject.FabricSpecificDetails.VmwareSiteId -friendlyName 'MyServer'  
  
Get-AzRecoveryServicesAsrProtectableItem: Operation failed.  
Protectable machine MyServer not found in the Site /subscriptions/1111/resourceGroups/MyRG/providers/Microsoft.OffAzure/VMwareSites/MyVault-a32d1vmwaresite.  
  
  

However, I see this VM in the portal when I click the +Replicate button

Azure Site Recovery
Azure Site Recovery
An Azure native disaster recovery service. Previously known as Microsoft Azure Hyper-V Recovery Manager.
693 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Christopher Lewis 21 Reputation points
    2022-08-04T19:22:08.233+00:00

    I've got 200 servers in the AllServers variable. (Could this be a paging issue??? )

    Sample ($allservers[0]) output:

    > $allservers.count  
    200  
    
    > $allservers[0]  
    Disks                         : {scsi0:0, scsi1:0, scsi1:1, scsi1:2…}  
    FabricObjectId                : /subscriptions/11-22-333/resourceGroups/MyRG/providers/Microsoft.OffAzure/VMwareSites/MyVault-a32d1vmwaresite/machines/vsphere_GUID  
    FabricSiteId                  : /subscriptions/11-22-333/resourceGroups/MyRG/providers/Microsoft.OffAzure/VMwareSites/MyVault-a32d1vmwaresite  
    FabricSpecificVMDetails       : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRInMageRcmSpecificVMDetails  
    FriendlyName                  : MyServer123  
    ID                            : /subscriptions/11-22-333/resourceGroups/MyRG/providers/Microsoft.OffAzure/VMwareSites/MyVault-a32d1vmwaresite/machines/vsphere_GUID  
    Name                          : vsphere_GUID  
    OS                            : windowsGuest  
    OSDiskId                      :   
    OSDiskName                    :   
    ProtectionContainerId         : /Subscriptions/11-22-333/resourceGroups/MyRG/providers/Microsoft.RecoveryServices/vaults/prd-usce-asr-vlt/replicationFabrics/prd-   
                                    usce-asr-vlt-vmwarefabric/replicationProtectionContainers/MyVault-a32d1replicationcontainer  
    ProtectionReadinessErrors     :   
    ProtectionStatus              : Protectable  
    ReplicationProtectedItemId    :   
    SupportedReplicationProviders : {InMageRcm}  
    

    Exclduing the -SiteId $ASRFabricObject.FabricSpecificDetails.VmwareSiteId variable results in nulls. -SiteID is required to retrieve any information

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.