You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Cmdlet based on description should always return an IList.
But it actually varies based on content.
Debug Output
Instructions: to get Debug Output, set $DebugPreference="Continue" and then execute the cmdlet or script causing the issue
Script/Steps for Reproduction
Below we can see since Product 58a4aeac497000007d060002 contains multiple subscriptions, then the output is Array. But if the product like 58a4aeac497000007d060001 contains just one Subscription, the output is PsApiManagementSubscription
The advice is to always enumerate collections in your output (i.e. WriteOuput(myCollection, true). PowerShell automatically unwraps single object collections returned as output. For cmdlets that can return both a single object or a list of objects, you can include bot the object type and the enumerable (i.e. OutputType(typeof(foo), typeof(IList)), you can also use the optional string parameter to associate these with parameter sets, as described here: https://msdn.microsoft.com/en-us/library/ee857075(v=vs.85).aspx
Cmdlet(s)
Get-AzureRmApiManagementSubscription
PowerShell Version
4.4.0
Module Version
AzureRm.ApiManagement
OS Version
Any
Description
The Cmdlet based on description should always return an IList.
But it actually varies based on content.
Debug Output
Instructions: to get Debug Output, set
$DebugPreference="Continue"
and then execute the cmdlet or script causing the issueScript/Steps for Reproduction
Below we can see since Product 58a4aeac497000007d060002 contains multiple subscriptions, then the output is Array. But if the product like 58a4aeac497000007d060001 contains just one Subscription, the output is PsApiManagementSubscription
PS C:\WINDOWS\system32> $result = Get-AzureRmApiManagementSubscription -Context $context -ProductId 58a4aeac497000007d060002
PS C:\WINDOWS\system32> $result.GetType()
True True Object[] System.Array
PS C:\WINDOWS\system32> $result = Get-AzureRmApiManagementSubscription -Context $context -ProductId 58a4aeac497000007d060001
PS C:\WINDOWS\system32> $result.GetType()
True False PsApiManagementSubscription System.Object
The text was updated successfully, but these errors were encountered: