Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Remove-AzContext

Remove a context from the set of available contexts

Syntax

RemoveByInputObject (Default)

Remove-AzContext
 -InputObject <PSAzureContext>
 [-Force]
 [-PassThru]
 [-Scope <ContextModificationScope>]
 [-DefaultProfile <IAzureContextContainer>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

RemoveByName

Remove-AzContext
 [-Name] <String>
 [-Force]
 [-PassThru]
 [-Scope <ContextModificationScope>]
 [-DefaultProfile <IAzureContextContainer>]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

Description

Remove an azure context from the set of contexts

Examples

Example 1

Remove-AzContext -Name Default

Remove the context named default

Parameters

-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

-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

-Force

Remove context even if it is the default

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-InputObject

A context object, normally passed through the pipeline.

Parameter properties

Type:PSAzureContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Name

The name of the context

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-PassThru

Return the removed context

Parameter properties

Type:SwitchParameter
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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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

PSAzureContext

Outputs

PSAzureContext


Feedback

Was this page helpful?