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-AzAccountOnce 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.

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 CurrentUserYou may also like following the articles below
- 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 !!!

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
