Search code examples
azuresubscriptionazure-powershellpowershell-cmdlet

Not able to select subscription ID in azure


I am using below code to select subscription id in Power shell script, but when i click on the subscription id it does not select...

$subscriptionId = (Get-AzureRmSubscription | Out-GridView -Title 'Select Azure Subscription:' -PassThru).SubscriptionId Select-AzureRmSubscription -SubscriptionId $subscriptionId


Solution

  • We can use this script to do it:

    $subscriptionId = (Get-AzureRmSubscription | Out-GridView -Title 'Select Azure Subscription:' -PassThru).Id 
    Select-AzureRmSubscription -SubscriptionId $subscriptionId
    

    We should use Id, not SubscriptionId, we can find the output here:

    PS C:\Users\v-jianye> Get-AzureRmSubscription
    
    Name     : Visual Studio Ultimate with MSDN
    Id       : 5384xxxx-xxxx-xxxx-xxxx-xxxxe29axxxx
    TenantId : 1fcfxxxx-xxx-4c99-9449-d8e18bf8xxxx
    State    : Enabled