Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Disconnect-AzAccount
- Module:
- Az.Accounts Module
Disconnects a connected Azure account and removes all credentials and contexts associated with that account.
Syntax
ContextName (Default)
Disconnect-AzAccount
[-ContextName <String>]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
UserId
Disconnect-AzAccount
[-Username] <String>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ServicePrincipal
Disconnect-AzAccount
-ApplicationId <String>
-TenantId <String>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
AccountObject
Disconnect-AzAccount
[-InputObject] <PSAzureRmAccount>
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ContextObject
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
-ApplicationId
ServicePrincipal id (globally unique id)
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | SPN, ServicePrincipal |
Parameter sets
-AzureContext
Context
Parameter properties
| Type: | PSAzureContext |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-ContextName
Name of the context to log out of
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DefaultProfile
The credentials, tenant and subscription used for communication with azure
Parameter properties
| Type: | IAzureContextContainer |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
-InputObject
The account object to remove
Parameter properties
| Type: | PSAzureRmAccount |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Scope
Determines the scope of context changes, for example, whether changes apply only to the current process, or to all sessions started by this user.
Parameter properties
| Type: | ContextModificationScope |
| Default value: | None |
| Accepted values: | Process, CurrentUser |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TenantId
Tenant id (globally unique id)
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Username
User name of the form 'user@contoso.org'
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Id, UserId |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not executed.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
PSAzureRmAccount
PSAzureContext
Outputs
PSAzureRmAccount
Azure PowerShell
Feedback
Was this page helpful?
