Add-​Azure​Rm​Account

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

Syntax

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

Description

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

You can use this authenticated account only with Azure 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 login

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

This command adds an Azure Resource Manager account.

To run Azure Resource Manager cmdlets with 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 in using the interactive option or use service principal authentication.

Example 2: Add an account that authenticates with organizational ID credentials

PS C:\>$Credential = Get-Credential
PS C:\> Add-AzureRmAccount -Credential $Credential
Account: azureuser@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 an Azure Resource Manager account with the credentials in $Credential.

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

Example 3: Add an account that authenticates with 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 an Azure Resource Manager account with the credentials stored in $Credential for the specified Tenant. The ServicePrincipal switch 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 an Azure Resource Manager account to run cmdlets for the specified tenant and subscription by default.

Required Parameters

-AccessToken

Specifies an access token.

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

Account Id for access token

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

SPN

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

Certificate Hash (Thumbprint)

Type:String
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
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SubscriptionName

Subscription Name

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
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
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Environment

Environment containing the account to log into

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

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

Type:String
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, the first subscription from the subscription list is used.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-TenantId

Optional tenant name or ID

Type:String
Aliases:Domain
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
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

PSAzureProfile