In this Azure PowerShell article, we will discuss the syntax and usage of the Disconnect-AzAccount Azure PowerShell cmdlet with examples.
Table of Contents
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 will 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 will try executing any Azure PowerShell cmdlet, it will ask you to run the Connect-AzAccount to log in first. See below for your reference.

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:
Below Azure PowerShell cmdlet will help you to log out from a specific context named “test” from the current user scope from where all the credentials along with the contexts will get deleted permanently.
Get-AzContext "test" | Disconnect-AzAccount -Scope CurrentUser
You may also like following the below articles
- Clear-AzContext
- Get-AzLocation
- Get-AzDeployment
- How to Create Azure Free Account (Step by Step tutorial)
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 !!!