external help file | Module Name | online version | schema | content_git_url | original_content_git_url |
---|---|---|---|---|---|
Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml |
Az.Accounts |
2.0.0 |
Get subscriptions that the current account can access.
Get-AzSubscription [-SubscriptionId <String>] [-TenantId <String>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Get-AzSubscription [-SubscriptionName <String>] [-TenantId <String>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
The Get-AzSubscription cmdlet gets the subscription ID, subscription name, and home tenant for subscriptions that the current account can access.
Get-AzSubscription
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Subscription2 xxxx-xxxx-xxxx-xxxx aaaa-aaaa-aaaa-aaaa Enabled
Subscription3 zzzz-zzzz-zzzz-zzzz bbbb-bbbb-bbbb-bbbb Enabled
This command gets all subscriptions in all tenants that are authorized for the current account.
Get-AzSubscription -TenantId "aaaa-aaaa-aaaa-aaaa"
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Subscription2 xxxx-xxxx-xxxx-xxxx aaaa-aaaa-aaaa-aaaa Enabled
List all subscriptions in the given tenant that are authorized for the current account.
Get-AzSubscription -TenantId (Get-AzContext).Tenant
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Subscription2 xxxx-xxxx-xxxx-xxxx aaaa-aaaa-aaaa-aaaa Enabled
This command gets all subscriptions in the current tenant that are authorized for the current user.
Get-AzSubscription -SubscriptionId "xxxx-xxxx-xxxx-xxxx" -TenantId "yyyy-yyyy-yyyy-yyyy" | Set-AzContext
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxx-xxxx-xxxx-xxxx) azureuser@micros... Subscription1 AzureCloud yyyy-yyyy-yyyy-yyyy
This command gets the specified subscription, and then sets the current context to use it. All subsequent cmdlets in this session use the new subscription (Contoso Subscription 1) by default.
Run cmdlet in the background and return a Job to track progress.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The credentials, tenant and subscription used for communication with azure
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the ID of the subscription to get.
Type: System.String
Parameter Sets: ListByIdInTenant
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the name of the subscription to get.
Type: System.String
Parameter Sets: ListByNameInTenant
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the ID of the tenant that contains subscriptions to get.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.