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

Get-AzureRmSnapshot unexpected behavior if ResourceGroupName is not specified

Open akirsman opened this issue 9 years ago • 4 comments

Cmdlet(s)

Get-AzureRmSnapshot

PowerShell Version

5.1.15063.608

Module Version

10.0.15063.608

OS Version

10.0.15063.608

Description

Hi, I just noticed a bug or confusing behavior in the Get-AzureRmSnapshot cmdlet (AzureRM.Compute module version 3.4.0):

If one calls it with -Name param without -ResourceGroupName param, it behaves at calling it without params. That is, Get-AzureRmSnapshot -SnapshotName blah returns all snaphots, as Get-AzureRmSnapshot. Only when called with -ResourceGroupName param it behaves as expected (error if it doesn't exist, or returns the snapshot object).

Debug Output

Script/Steps for Reproduction

Get-AzureRmSnapshot -SnapshotName, or Get-AzureRmSnapshot -Name

akirsman avatar Oct 14 '17 18:10 akirsman

@singhkays Looks like a potential issue int he parameter sets for Get-AzreRmVM. Can you take a look?

markcowl avatar Oct 16 '17 15:10 markcowl

@akirsman We're looking into adding parameter sets to this cmdlet which should make this behavior go away. However, there's no API to search by snapshot name, so the parmaeter sets will be RG + Name, RG or no parameters to list all snapshots in the subscription.

cc: @hyonholee

singhkays avatar Oct 16 '17 17:10 singhkays

@singhkays @hyonholee Any update on this issue?

maddieclayton avatar Mar 10 '18 01:03 maddieclayton

I will include this in the fix for this issue: https://github.com/Azure/azure-powershell/issues/6549 - I will ensure that getting by name only works for all cmdlets, and that the parameter sets are set up to work for retrieving by name only.

maddieclayton avatar Jan 28 '19 21:01 maddieclayton