Disconnect-AzAccount

In this Azure PowerShell article, we will discuss the syntax and usage of the Disconnect-AzAccount Azure PowerShell cmdlet with examples.

Disconnect-AzAccount

Disconnect-AzAccount is an excellent Azure PowerShell cmdlet that can help you to disconnect an Azure account that you are connected currently. With that, it also removes all the credentials and the contexts associated with your current Azure account.

Syntax

Below is the syntax of the Disconnect-AzAccount Azure PowerShell cmdlet.

Disconnect-AzAccount [-ContextName <String>] [-Scope <ContextModificationScope>]

Example – 1

If you execute the below Azure PowerShell cmdlet, you will get the below output.

Disconnect-AzAccount

Once you run the above Azure PowerShell cmdlet, it will disconnect the Azure account and all the dependencies, including the credentials and contexts, etc. After that, once you try executing any Azure PowerShell cmdlet, it will ask you to run the Connect-AzAccount to log in first. See below for your reference.

Disconnect-AzAccount

Example-2:

Below Azure PowerShell cmdlet will help you to log out a specific user named ‘testuser1@tsinfo.com’.

Disconnect-AzAccount -Username 'testuser1@tsinfo.com'

Example-3:

The Azure PowerShell cmdlet will help you log out from a specific context named “test” from the current user scope, where all the credentials and the contexts will get deleted permanently.

Get-AzContext "test" | Disconnect-AzAccount -Scope CurrentUser

You may also like following the articles below

Wrapping Up

In this article, we have discussed the syntax and usage of the Disconnect-AzAccount Azure PowerShell cmdlet with examples. Thanks for reading this article !!!