Do you need to connect with your AzAccount or Azure subscription however usually are not certain what cmdlet to make use of? You want the Join-AzAccount cmdlet, and this information teaches you all about this cmdlet.
By Victor Ashiedu | Up to date February 17, 2023 | 7 minutes learn
To make this text straightforward to learn, I’ve divided them into sections, beginning with an summary of this cmdlet. Furthermore, earlier than you need to use the Join-AzAccount cmdlet, it’s worthwhile to set up the Az.Accounts PowerShell module.
So, within the second part, I’ll present you the best way to set up the Az.Accounts PowerShell module. Upon getting this module in your pc, you’ll be able to proceed to learn the syntaxes and parameters of the Join-AzAccount cmdlet.
Then comes the thrilling bit in part 4 – examples and functions of this cmdlet. Lastly, I included an FAQ part the place I reply frequent questions SysAdmins ask about this Azure PowerShell cmdlet.
Overview of the Join-AzAccount Cmdlet

As I hinted in my introduction, the Join-AzAccount cmdlet is a part of the Az.Accounts PowerShell module. So, in case you attempt to run this command with out putting in this module, you’ll obtain an error message – see the screenshot under.

In the meantime, this cmdlet connects you to an Azure tenant with an authenticated account. When you connect with Azure with the Join-AzAccount cmdlet, you need to use the opposite cmdlets within the Az PowerShell module.
Within the final paragraph, I discussed that you simply want an authenticated account to make use of Join-AzAccount to connect with Azure. Based mostly on this, it is strongly recommended to make use of the Get-Credential command to save lots of your authenticated credentials in a variable.
Then, use the -Credential parameter of the Join-AzAccount cmdlet to connect with your Azure tenant.
Earlier than I transfer on from this overview part, I’ll additionally like to say that the Join-AzAccount cmdlet has two different aliases – Login-AzAccount and Add-AzAccount. So because of this you need to use Login-AzAccount or Add-AzAccount as a substitute of Join-AzAccount.
With the fundamentals out of the way in which, let’s now transfer on to the juicy elements of this text!
Find out how to Set up the Az.Accounts PowerShell Module

I’ve already talked about greater than as soon as on this article that it’s worthwhile to set up the Az.Accounts PowerShell module earlier than you need to use the Join-AzAccount cmdlet.
Comply with the steps under to put in the Az.Accounts PowerShell module.
- Seach PowerShell. Then, from the search outcomes, click on Run as Administrator. Your Home windows PC will ask you to permit the app to make modifications to your PC – click on Sure.

- Then, when PowerShell opens, copy and paste the command under. Then, press the enter key in your keyboard to run the command.
Set up-Module -Title Az.Accounts -Pressure
When PowerShell finishes putting in the module, once you run the Join-AzAccount command, PowerShell will immediate you on your credentials.

Nonetheless, earlier than we begin taking part in round with this cmdlet, let’s be taught its syntaxes and parameters first. I’ll cowl these within the subsequent two sections.
Earlier I discussed that the Join-AzAccount cmdlet has two different aliases – Login-AzAccount and Add-AzAccount. Now that you’ve put in the Az.Accounts module, you’ll be able to run the command under to verify that Login-AzAccount and Add-AzAccount are the aliases of Join-AzAccount.
Get-Alias | ? {$_.Title -like "*AzAccount*"} | Choose-Object identify, ReferencedCommand
Right here is the screenshot of the results of the command. I’ve highlighted the a part of the outcome that exhibits that Login-AzAccount and Add-AzAccount are the aliases of Join-AzAccount.

Syntaxes of the Join-AzAccount Cmdlet

The Join-AzAccount cmdlet has 8 syntaxes. Right here they’re…
I perceive that wanting on the 8 syntaxes presents an issue. Particularly, it’s obscure the variations between the syntaxes. So, after the syntaxes, I’ve supplied a short clarification of what differentiates the syntaxes.
Join-AzAccount [-Environment <String>] [-Tenant <String>] [-AccountId <String>] [-Subscription <String>] [-AuthScope <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-UseDeviceAuthentication] [-Force] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] -Credential <PSCredential> [-ServicePrincipal] -Tenant <String> [-Subscription <String>] [-AuthScope <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] -Credential <PSCredential> [-Tenant <String>] [-Subscription <String>] [-AuthScope <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] -CertificateThumbprint <String> -ApplicationId <String> [-ServicePrincipal] -Tenant <String> [-Subscription <String>] [-AuthScope <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-SendCertificateChain] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] -ApplicationId <String> [-ServicePrincipal] -Tenant <String> [-Subscription <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] -FederatedToken <String> [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] -ApplicationId <String> [-ServicePrincipal] -Tenant <String> [-Subscription <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-SendCertificateChain] -CertificatePath <String> [-CertificatePassword <SecureString>] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] [-Tenant <String>] -AccessToken <String> [-GraphAccessToken <String>] [-MicrosoftGraphAccessToken <String>] [-KeyVaultAccessToken <String>] -AccountId <String> [-Subscription <String>] [-ContextName <String>] [-SkipValidation] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Join-AzAccount [-Environment <String>] [-Tenant <String>] [-AccountId <String>] [-Identity] [-Subscription <String>] [-AuthScope <String>] [-ContextName <String>] [-SkipContextPopulation] [-MaxContextPopulation <Int32>] [-Force] [-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Parameters of the Join-AzAccount Cmdlet Defined

Within the final part, I listed and defined the 8 syntaxes of the Join-AzAccount cmdlet. Within the desk under, I’ve defined the parameters that make up the syntaxes of 6he command.
Join-AzAccount Parameter Title | Parameter Which means/Notes |
---|---|
Atmosphere | The Atmosphere parameter specifies the surroundings of the Azure account. |
Tenant | Use the Tenant parameter to specify the ID or identify of the Azure Tenant you want to connect with. |
AccountId | While you specify the AccountId parameter, enter the Azure Account Id, Consumer Id, or the Consumer Title of the account you need to register with. |
Subscription | Use this parameter to specify the Azure Subscription |
AuthScope | This parameter specifies an non-compulsory OAuth scope for login. The AuthScope parameter of the Join-AzAccount cmdlet accepts any of the next: AadGraph, AnalysisServices, Attestation, Batch, DataLake, KeyVault, OperationalInsights, Storage, Synapse. |
ContextName | Use the ContextName parameter to specify the identify of the default Azure context for the present login with Join-AzAccount. |
SkipContextPopulation | It is a SwitchParameter, which signifies that it doesn’t require any enter. While you specify the SkipContextPopulation parameter, Join-AzAccount skips populating context if no contexts are discovered. |
References and Additional Studying
- PowerShell Gallery | Az.Accounts 2.2.3
- Join-AzAccount (Az.Accounts) | Microsoft Be taught
- Join-AzAccount: Your Gateway To Azure with PowerShell (adamtheautomator.com)