diff --git a/src/ResourceManager/Profile/Commands.Profile/ChangeLog.md b/src/ResourceManager/Profile/Commands.Profile/ChangeLog.md index b412e1ad06fd..4143ac792613 100644 --- a/src/ResourceManager/Profile/Commands.Profile/ChangeLog.md +++ b/src/ResourceManager/Profile/Commands.Profile/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Current Release +* Fix issue with Get-AzureRmSubscription in CloudShell ## Version 5.6.0 * Minor changes to the storage common code diff --git a/src/ResourceManager/Profile/Commands.Profile/Subscription/GetAzureRMSubscription.cs b/src/ResourceManager/Profile/Commands.Profile/Subscription/GetAzureRMSubscription.cs index f20eb8a295ab..3d9f80aeea72 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Subscription/GetAzureRMSubscription.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Subscription/GetAzureRMSubscription.cs @@ -104,8 +104,24 @@ public override void ExecuteCmdlet() { try { - var subscriptions = _client.ListSubscriptions(tenant); - WriteObject(subscriptions.Select((s) => new PSAzureSubscription(s)), enumerateCollection: true); + if (DefaultContext.Account.Type.Equals("ManagedService")) + { + if (tenant == null) + { + tenant = DefaultContext.Tenant.Id; + } + + if (tenant.Equals(DefaultContext.Tenant.Id)) + { + var subscriptions = _client.ListSubscriptions(tenant); + WriteObject(subscriptions.Select((s) => new PSAzureSubscription(s)), enumerateCollection: true); + } + } + else + { + var subscriptions = _client.ListSubscriptions(tenant); + WriteObject(subscriptions.Select((s) => new PSAzureSubscription(s)), enumerateCollection: true); + } } catch (AadAuthenticationException exception) {