Set-AzContext

Legt den Mandanten, das Abonnement und die Umgebung für Cmdlets fest, die in der aktuellen Sitzung verwendet werden sollen.

Syntax

Set-AzContext
   [-Context] <PSAzureContext>
   [-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
   [-Name <String>]
   [-Force]
   [-Scope <ContextModificationScope>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzContext
   [-TenantObject] <PSAzureTenant>
   [-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
   [-Name <String>]
   [-Force]
   [-Scope <ContextModificationScope>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzContext
   [-SubscriptionObject] <PSAzureSubscription>
   [-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
   [-Name <String>]
   [-Force]
   [-Scope <ContextModificationScope>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzContext
   [-Tenant <String>]
   [-Subscription] <String>
   [-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
   [-Name <String>]
   [-Force]
   [-Scope <ContextModificationScope>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzContext
   -Tenant <String>
   [-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
   [-Name <String>]
   [-Force]
   [-Scope <ContextModificationScope>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Beschreibung

Das Cmdlet Set-AzContext legt Authentifizierungsinformationen für Cmdlets fest, die Sie in der aktuellen Sitzung ausführen. Der Kontext umfasst Mandanten-, Abonnement- und Umgebungsinformationen.

Beispiele

Beispiel 1: Festlegen des Abonnementkontexts

Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"

Name    Account             SubscriptionName    Environment         TenantId
----    -------             ----------------    -----------         --------
Work    test@outlook.com    Subscription1       AzureCloud          xxxxxxxx-x...

Dieser Befehl legt den Kontext fest, um das angegebene Abonnement zu verwenden.

Parameter

-Confirm

Hiermit werden Sie vor der Ausführung des Cmdlets zur Bestätigung aufgefordert.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Context

Gibt den Kontext für die aktuelle Sitzung an.

Type:PSAzureContext
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-DefaultProfile

Die Anmeldeinformationen, Mandanten und Abonnements, die für die Kommunikation mit Azure verwendet werden.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ExtendedProperty

Zusätzliche Kontexteigenschaften

Type:IDictionary<TKey,TValue>[System.String,System.String]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Force

Überschreiben Sie den vorhandenen Kontext mit demselben Namen, falls vorhanden.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Name

Name des Kontexts

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Scope

Bestimmt den Umfang der Kontextänderungen, z. B. ob Änderungen nur für den aktuellen Prozess gelten oder auf alle Sitzungen, die von diesem Benutzer gestartet wurden.

Type:ContextModificationScope
Accepted values:Process, CurrentUser
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Subscription

Der Name oder die ID des Abonnements, auf das der Kontext festgelegt werden soll. Dieser Parameter verfügt über Aliase zu -SubscriptionName und -SubscriptionId, sodass eine der folgenden Elemente anstelle von -Abonnement verwendet werden kann, wenn Sie Namen und ID angeben.

Type:String
Aliases:SubscriptionId, SubscriptionName
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SubscriptionObject

Ein Abonnementobjekt

Type:PSAzureSubscription
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-Tenant

Mandantendomänenname oder ID

Type:String
Aliases:Domain, TenantId
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TenantObject

Ein Mandantenobjekt

Type:PSAzureTenant
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-WhatIf

Zeigt, was geschieht, wenn das Cmdlet ausgeführt wird. Das Cmdlet wird nicht ausgeführt.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Eingaben

PSAzureContext

PSAzureTenant

PSAzureSubscription

Ausgaben

PSAzureContext