Add-AzureRmAccount

Adds an authenticated account to use for Resource Manager cmdlet requests.

Syntax

Add-AzureRmAccount [-AccessToken <String>] [-Credential <PSCredential>] [-EnvironmentName <String>]
 [-SubscriptionId <String>] [-AccountId <String>] [-ApplicationId <String>] [-CertificateThumbprint <String>]
 [-Confirm] [-Environment <AzureEnvironment>] [-TenantId <String>] [-WhatIf] [<CommonParameters>]
Add-AzureRmAccount [-AccessToken <String>] [-Credential <PSCredential>] [-EnvironmentName <String>]
 [-SubscriptionName <String>] [-AccountId <String>] [-ApplicationId <String>] [-CertificateThumbprint <String>]
 [-Confirm] [-Environment <AzureEnvironment>] [-TenantId <String>] [-WhatIf] [<CommonParameters>]
Add-AzureRmAccount -AccessToken <String> [-EnvironmentName <String>] -AccountId <String> [-Confirm]
 [-Environment <AzureEnvironment>] [-TenantId <String>] [-WhatIf] [<CommonParameters>]
Add-AzureRmAccount [-Credential <PSCredential>] [-EnvironmentName <String>] [-Confirm]
 [-Environment <AzureEnvironment>] [-TenantId <String>] [-WhatIf] [<CommonParameters>]
Add-AzureRmAccount -Credential <PSCredential> [-EnvironmentName <String>] [-ServicePrincipal]
 [-SubscriptionId <String>] [-SubscriptionName <String>] [-Confirm] [-Environment <AzureEnvironment>]
 -TenantId <String> [-WhatIf] [<CommonParameters>]
Add-AzureRmAccount [-EnvironmentName <String>] [-ServicePrincipal] -ApplicationId <String>
 -CertificateThumbprint <String> [-Confirm] [-Environment <AzureEnvironment>] -TenantId <String> [-WhatIf]
 [<CommonParameters>]

Description

The Add-AzureRmAccount cmdlet adds an authenticated Azure account to use for Azure Resource Manager cmdlet requests.

You can use this authenticated account only with Resource Manager cmdlets. To add an authenticated account for use with Service Management cmdlets, use the Add-AzureAccount or the Import-AzurePublishSettingsFile cmdlet.

Examples

Example 1: Add an account that requires interactive logon

PS C:\>Add-AzureRmAccount
Account: pfuller@contoso.com
Environment: AzureCloud
Subscription: xxxx-xxxx-xxxx-xxxx
Tenant: xxxx-xxxx-xxxx-xxxx

This command adds an Azure Resource Manager account.

To run Resource Manager cmdlets by using this account, you must provide Microsoft account or organizational ID credentials at the prompt. If multi-factor authentication is enabled for your credentials, you must log on by using the interactive option or use service principal authentication.

Example 2: Add an account that authenticates by using organizational ID credentials

PS C:\>$Credential = Get-Credential
PS C:\> Add-AzureRmAccount -Credential $Credential
Account: pfuller@contoso.com
Environment: AzureChinaCloud
Subscription: xxxx-xxxx-xxxx-xxxx
Tenant: xxxx-xxxx-xxxx-xxxx

The first command gets the user credentials, and then stores them in the $Credential variable.

The second command adds a Resource Manager account that has the credentials in $Credential.

This account authenticates with Resource Manager using organizational ID credentials. You cannot use multi-factor authentication or Microsoft account credentials to run Resource Manager cmdlets by using this account.

Example3: Add an account that authenticates by using service principal credentials

PS C:\>$Credential = Get-Credential
PS C:\> Add-AzureRmAccount -Credential $Credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -ServicePrincipal
Account: xxxx-xxxx-xxxx-xxxx
Environment: AzureCloud
Subscription: yyyy-yyyy-yyyy-yyyy
Tenant: xxxx-xxxx-xxxx-xxxx

The first command gets the user credentials, and then stores them in the $Credential variable.

The second command adds a Resource Manager account that has the credentials stored in $Credential for the specified Tenant. The ServicePrincipal parameter indicates that the account authenticates as a service principal.

Example 4: Add an account for a specific tenant and subscription

PS C:\>Add-AzureRmAccount -Tenant 'xxxx-xxxx-xxxx-xxxx' -SubscriptionId 'yyyy-yyyy-yyyy-yyyy'
Account: pfuller@contoso.com
Environment: AzureCloud
Subscription: yyyy-yyyy-yyyy-yyyy
Tenant: xxxx-xxxx-xxxx-xxxx

This command adds a Resource Manager account to run cmdlets for the specified tenant and subscription. By default, the session uses the account.

Parameters

-AccessToken

Specifies an access token.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies a PSCredential object. For more information about the PSCredential object, type Get-Help Get-Credential.

The PSCredential object provides the user ID and password for organizational ID credentials, or the application ID and secret for service principal credentials.

Type:PSCredential
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-EnvironmentName

Specifies the name of the environment.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ServicePrincipal

Indicates that this account authenticates by providing service principal credentials.

Type:SwitchParameter
Required:True
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SubscriptionId

Specifies the ID of the subscription. If you do not specify this parameter, this cmdlet uses the first subscription from the subscription list.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SubscriptionName

Specifies the name of the subscription.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-AccountId

Specifies the ID of an authenticated account that run Resource Manager cmdlets.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ApplicationId

Specifies an application ID.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-CertificateThumbprint

Specifies the thumbprint of a certificate.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Environment

Specifies the Azure environment. Valid values are: AzureCloud and AzureChinaCloud. The default is AzureCloud.

Type:AzureEnvironment
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TenantId

Specifies the ID of the tenant.

Type:String
Aliases:Domain
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False