Disconnect-AzAccount
Disconnects a connected Azure account and removes all credentials and contexts associated with that account.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
Disconnect-AzAccount
[-ContextName <String>]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Disconnect-AzAccount
[-Username] <String>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Disconnect-AzAccount
-ApplicationId <String>
-TenantId <String>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Disconnect-AzAccount
[-InputObject] <PSAzureRmAccount>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Disconnect-AzAccount
[-AzureContext] <PSAzureContext>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Disconnect-AzAccount cmdlet disconnects a connected Azure account and removes all credentials and contexts (subscription and tenant information) associated with that account. After executing this cmdlet, you will need to login again using Connect-AzAccount.
Examples
Example 1: Logout of the current account
Disconnect-AzAccount
Logs out of the Azure account associated with the current context.
Example 2: Logout of the account associated with a particular context
Get-AzContext "Work" | Disconnect-AzAccount -Scope CurrentUser
Logs out the account associated with the given context (named 'Work'). Because this uses the 'CurrentUser' scope, all credentials and contexts will be permanently deleted.
Example 3: Log out a particular user
Disconnect-AzAccount -Username 'user1@contoso.org'
Logs out the 'user1@contoso.org' user - all credentials and all contexts associated with this user will be removed.
Parameters
ServicePrincipal id (globally unique id)
| Type: | String |
| Aliases: | SPN, ServicePrincipal |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Context
| Type: | PSAzureContext |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
| Type: | SwitchParameter |
| Aliases: | cf |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Name of the context to log out of
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The credentials, tenant and subscription used for communication with azure
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The account object to remove
| Type: | PSAzureRmAccount |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Determines the scope of context changes, for example, whether changes apply only to the current process, or to all sessions started by this user.
| Type: | ContextModificationScope |
| Accepted values: | Process, CurrentUser |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Tenant id (globally unique id)
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
User name of the form 'user@contoso.org'
| Type: | String |
| Aliases: | Id, UserId |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not executed.
| Type: | SwitchParameter |
| Aliases: | wi |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |