Disconnect-AzAccount
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
Parameters
-ApplicationId
ServicePrincipal id (globally unique id)
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SPN, ServicePrincipal
Parameter sets
ServicePrincipal
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-AzureContext
Context
Parameter properties
Type: PSAzureContext
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ContextObject
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-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
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ContextName
Name of the context to log out of
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ContextName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-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
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
The account object to remove
Type: PSAzureRmAccount
Default value: None
Supports wildcards: False
DontShow: False
AccountObject
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-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
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-TenantId
Tenant id (globally unique id)
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ServicePrincipal
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Username
User name of the form '[email protected] '
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: Id, UserId
Parameter sets
UserId
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-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
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
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 .
Outputs