azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Get-AzRecoveryServicesBackupItem ability to filter according to exact VM name

Open assaf-sela opened this issue 5 years ago • 10 comments

When using the commnand Get-AzRecoveryServicesBackupItem with a VM name, a list of backup items containing the name is returned.

There should be a way to receive results with exact match of the vm name parameter

for example if I have 2 VMs with the name: VM1 and VM11, this command will return 2 items for each VM

$backupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType "AzureVM" -WorkloadType "AzureVM" -Name "VM1" -VaultId $vault.ID

I will have to perform filtering on the result to verify I get the exact VM item I was looking for

assaf-sela avatar Dec 24 '20 08:12 assaf-sela

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pvrk.

Issue Details

When using the commnand Get-AzRecoveryServicesBackupItem with a VM name, a list of backup items containing the name is returned.

There should be a way to receive results with exact match of the vm name parameter

for example if I have 2 VMs with the name: VM1 and VM11, this command will return 2 items for each VM

$backupItem = Get-AzRecoveryServicesBackupItem -BackupManagementType "AzureVM" -WorkloadType "AzureVM" -Name "VM1" -VaultId $vault.ID

I will have to perform filtering on the result to verify I get the exact VM item I was looking for

Author: assaf-grth
Assignees: -
Labels:

Recovery Services Backup, Service Attention, customer-reported, feature-request, question

Milestone: -

ghost avatar Dec 24 '20 08:12 ghost

@assaf-grth : For more details, can you please run the "Get-AzRecoveryServicesBackupContainer" cmdlet with the same parameters and let us know if that is giving the exact result?

pvrk avatar Dec 24 '20 12:12 pvrk

@assaf-grth : Can you also retry using the "FriendlyName" option instead of "-Name" option for "Get-AzRecoveryServicesBackupItem" cmdlet?

pvrk avatar Dec 24 '20 12:12 pvrk

I get even more results with names which are not related to my input

assaf-sela avatar Dec 24 '20 12:12 assaf-sela

I get even more results with names which are not related to my input

May I know the above response is for which query? Basically please run 2 commands (Get-AzBackupContainer and Get-AzBackupItem with Friendly name parameter) and please provide the response separately.

pvrk avatar Dec 28 '20 05:12 pvrk

I'm limited with the information I can provide Is there specific data you would like to inspect?

assaf-sela avatar Dec 28 '20 15:12 assaf-sela

@assaf-grth - We have tried the different combinations at our end and created a backlog item for the permanent fix. As a stop gap solution , can you please try the below: Run $container=Get-AzRecoveryServicesBackupContainer command and pass VM name as the value for -FriendlyName parameter. Now run the Get-AzRecoveryServicesBackupItem command with -Container parameter and pass the container variable as value for the parameter. Sample: $Container=Get-AzRecoveryServicesBackupContainer -ContainerType "AzureVM" -Status "Registered" -FriendlyName "testvm" -VaultId $vault.ID Get-AzRecoveryServicesBackupItem -Container $Container -WorkloadType AzureVM -VaultId $vault.ID -FriendlyName "testvm"

Please let us know if this works for you.

mepand avatar Dec 30 '20 08:12 mepand

@mepand I already figured a way The result of Get-AzRecoveryServicesBackupItem with -Name parameter is a name with this format: VM;container name;resource group name;vm name

On this string I filtered the vm I required using this command: $vmBackupItem = $backupItem | Where-Object {$_.Name.EndsWith(";$($vm)")}

In case I'll have different problems with this way I will try your suggestion

Thanks for the assistance

assaf-sela avatar Dec 30 '20 08:12 assaf-sela

Thanks for the quick response @assaf-grth . Glad to know that you are unblocked. As I mentioned above, we will be doing the permanent fix in one of the upcoming releases. Currently, since there is no more assistance needed from the PG team, I think we can close this issue. Incase you face some other issue, please feel free to reach out to us.

mepand avatar Dec 30 '20 17:12 mepand

@assaf-grth thanks for sharing your workaround, I ended up using the same 3 years later. It's funny how we expect flag like -Name to match on name EXACTLY and it seems like a blocker but then we forget about our ability to use PS to just weed the list down after it's returned to us. You unblocked me there

kaburkett avatar Feb 03 '23 19:02 kaburkett