Get-AzureRmSnapshot unexpected behavior if ResourceGroupName is not specified
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
@singhkays Looks like a potential issue int he parameter sets for Get-AzreRmVM. Can you take a look?
@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 @hyonholee Any update on this issue?
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.