Freigeben über


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 Set-AzContext-Cmdlet legt Authentifizierungsinformationen für Cmdlets fest, die Sie in der aktuellen Sitzung ausführen. Der Kontext umfasst Informationen zu Mandant, Abonnement und Umgebung.

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...

Mit diesem Befehl wird der Kontext für die Verwendung des angegebenen Abonnements festgelegt.

Parameter

-Confirm

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

Typ:SwitchParameter
Aliases:cf
Position:Named
Standardwert:False
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

-Context

Gibt den Kontext für die aktuelle Sitzung an.

Typ:PSAzureContext
Position:0
Standardwert:None
Erforderlich:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

Die Anmeldeinformationen, der Mandant und das Abonnement, die für die Kommunikation mit Azure verwendet werden.

Typ:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Standardwert:None
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

-ExtendedProperty

Zusätzliche Kontexteigenschaften

Typ:IDictionary<TKey,TValue>[System.String,System.String]
Position:Named
Standardwert:None
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Überschreiben Sie ggf. den vorhandenen Kontext mit demselben Namen.

Typ:SwitchParameter
Position:Named
Standardwert:None
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Name des Kontexts

Typ:String
Position:Named
Standardwert:None
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

-Scope

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

Typ:ContextModificationScope
Zulässige Werte:Process, CurrentUser
Position:Named
Standardwert:None
Erforderlich:False
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". Aus Gründen der Übersichtlichkeit kann also eine dieser Aliase anstelle von -Subscription verwendet werden, wenn Name und ID angegeben werden.

Typ:String
Aliases:SubscriptionId, SubscriptionName
Position:0
Standardwert:None
Erforderlich:True
Accept pipeline input:False
Accept wildcard characters:False

-SubscriptionObject

Ein Abonnementobjekt

Typ:PSAzureSubscription
Position:0
Standardwert:None
Erforderlich:True
Accept pipeline input:True
Accept wildcard characters:False

-Tenant

Mandant do Standard Name oder ID

Typ:String
Aliases:Domain, TenantId
Position:Named
Standardwert:None
Erforderlich:True
Accept pipeline input:False
Accept wildcard characters:False

-TenantObject

Ein Mandantenobjekt

Typ:PSAzureTenant
Position:0
Standardwert:None
Erforderlich:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

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

Typ:SwitchParameter
Aliases:wi
Position:Named
Standardwert:False
Erforderlich:False
Accept pipeline input:False
Accept wildcard characters:False

Eingaben

PSAzureContext

PSAzureTenant

PSAzureSubscription

Ausgaben

PSAzureContext