Skip to content

Split Az.Accounts examples #16880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Accounts/Accounts/help/Add-AzEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ The built-in environments AzureCloud and AzureChinaCloud target existing public
## EXAMPLES

### Example 1: Creating and modifying a new environment
```
PS C:\> Add-AzEnvironment -Name TestEnvironment `
```powershell
Add-AzEnvironment -Name TestEnvironment `
-ActiveDirectoryEndpoint TestADEndpoint `
-ActiveDirectoryServiceEndpointResourceId TestADApplicationId `
-ResourceManagerEndpoint TestRMEndpoint `
Expand All @@ -70,7 +70,7 @@ Name Resource Manager Url ActiveDirectory Authority
---- -------------------- -------------------------
TestEnvironment TestRMEndpoint TestADEndpoint/

PS C:\> Set-AzEnvironment -Name TestEnvironment `
Set-AzEnvironment -Name TestEnvironment `
-ActiveDirectoryEndpoint NewTestADEndpoint `
-GraphEndpoint NewTestGraphEndpoint | Format-List

Expand Down Expand Up @@ -110,7 +110,7 @@ BatchEndpointResourceId :
In this example we are creating a new Azure environment with sample endpoints using Add-AzEnvironment, and then we are changing the value of the ActiveDirectoryEndpoint and GraphEndpoint attributes of the created environment using the cmdlet Set-AzEnvironment.

### Example 2: Discovering a new environment via Uri
```
```powershell
<#
Uri https://configuredmetadata.net returns an array of environment metadata. The following example contains a payload for the AzureCloud default environment.

Expand Down Expand Up @@ -149,8 +149,10 @@ Uri https://configuredmetadata.net returns an array of environment metadata. The
]
#>

PS C:\> Add-AzEnvironment -AutoDiscover -Uri https://configuredmetadata.net
Add-AzEnvironment -AutoDiscover -Uri https://configuredmetadata.net
```

```Output
Name Resource Manager Url ActiveDirectory Authority
---- -------------------- -------------------------
TestEnvironment TestRMEndpoint TestADEndpoint/
Expand Down
2 changes: 1 addition & 1 deletion src/Accounts/Accounts/help/Clear-AzContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Remove all Azure Credentials, account, and subscription information.

### Example 1: Clear global context
```powershell
PS C:\> Clear-AzContext -Scope CurrentUser
Clear-AzContext -Scope CurrentUser
```

Remove all account, subscription, and credential information for any powershell session.
Expand Down
4 changes: 2 additions & 2 deletions src/Accounts/Accounts/help/Clear-AzDefault.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ the user depending on the switch parameters specified by the user.

### Example 1
```powershell
PS C:\> Clear-AzDefault
Clear-AzDefault
```

This command removes all the defaults set by the user in the current context.

### Example 2
```powershell
PS C:\> Clear-AzDefault -ResourceGroup
Clear-AzDefault -ResourceGroup
```

This command removes the default resource group set by the user in the current context.
Expand Down
2 changes: 1 addition & 1 deletion src/Accounts/Accounts/help/Disable-AzContextAutosave.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Turn off autosaving Azure credentials. Your login information will be forgotten

### Example 1: Disable autosaving the context
```powershell
PS C:\> Disable-AzContextAutosave
Disable-AzContextAutosave
```

Disable autosave for the current user.
Expand Down
10 changes: 5 additions & 5 deletions src/Accounts/Accounts/help/Disable-AzureRmAlias.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Disables AzureRm prefix aliases for Az modules. If -Module is specified, only mo
## EXAMPLES

### Example 1
```
PS C:\> Disable-AzureRmAlias
```powershell
Disable-AzureRmAlias
```

Disables all AzureRm prefixes for the current PowerShell session.

### Example 1
```
PS C:\> Disable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
### Example 2
```powershell
Disable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
```

Disables AzureRm aliases for the Az.Accounts module for both the current process and for the current user.
Expand Down
6 changes: 3 additions & 3 deletions src/Accounts/Accounts/help/Disconnect-AzAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ After executing this cmdlet, you will need to login again using Connect-AzAccoun

### Example 1: Logout of the current account
```powershell
PS C:\> Disconnect-AzAccount
Disconnect-AzAccount
```

Logs out of the Azure account associated with the current context.

### Example 2: Logout of the account associated with a particular context
```powershell
PS C:\> Get-AzContext "Work" | Disconnect-AzAccount -Scope CurrentUser
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
```powershell
PS C:\> Disconnect-AzAccount -Username '[email protected]'
Disconnect-AzAccount -Username '[email protected]'
```

Logs out the '[email protected]' user - all credentials and all contexts associated with this user will be removed.
Expand Down
4 changes: 2 additions & 2 deletions src/Accounts/Accounts/help/Enable-AzureRmAlias.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Enables AzureRm prefix aliases for Az modules. If -Module is specified, only mod

### Example 1
```powershell
PS C:\> Enable-AzureRmAlias
Enable-AzureRmAlias
```

Enables all AzureRm prefixes for the current PowerShell session.

### Example 2
```powershell
PS C:\> Enable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
Enable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
```

Enables AzureRm aliases for the Az.Accounts module for both the current process and for the current user.
Expand Down
6 changes: 3 additions & 3 deletions src/Accounts/Accounts/help/Get-AzAccessToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ Get access token

### Example 1 Get the access token for ARM endpoint
```powershell
PS C:\> Get-AzAccessToken
Get-AzAccessToken
```

Get access token of current account for ResourceManager endpoint

### Example 2 Get the access token for Microsoft Graph endpoint
```powershell
PS C:\> Get-AzAccessToken -ResourceTypeName MSGraph
Get-AzAccessToken -ResourceTypeName MSGraph
```

Get access token of Microsoft Graph endpoint for current account

### Example 3 Get the access token for Microsoft Graph endpoint
```powershell
PS C:\> Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com/"
Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com/"
```

Get access token of Microsoft Graph endpoint for current account
Expand Down
10 changes: 7 additions & 3 deletions src/Accounts/Accounts/help/Get-AzContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ Azure Resource Manager cmdlets use these settings by default when making Azure R
## EXAMPLES

### Example 1: Getting the current context
```powershell
Connect-AzAccount
Get-AzContext
```
PS C:\> Connect-AzAccount
PS C:\> Get-AzContext

```Output
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1 AzureCloud xxxxxxxx-x...
Expand All @@ -43,9 +45,11 @@ Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1
In this example we are logging into our account with an Azure subscription using Connect-AzAccount, and then we are getting the context of the current session by calling Get-AzContext.

### Example 2: Listing all available contexts
```powershell
Get-AzContext -ListAvailable
```
PS C:\> Get-AzContext -ListAvailable

```Output
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1 AzureCloud xxxxxxxx-x...
Expand Down
8 changes: 6 additions & 2 deletions src/Accounts/Accounts/help/Get-AzContextAutosaveSetting.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ automatically saved, and where saved context and credential information can be f
## EXAMPLES

### Get context save metadata for the current session
```powershell
Get-AzContextAutosaveSetting
```
PS C:\> Get-AzContextAutosaveSetting

```Output
Mode : Process
ContextDirectory : None
ContextFile : None
Expand All @@ -39,9 +41,11 @@ Settings : {}
Get details about whether and where the context is saved. In the above example, the autosave feature has been disabled.

### Get context save metadata for the current user
```powershell
Get-AzContextAutosaveSetting -Scope CurrentUser
```
PS C:\> Get-AzContextAutosaveSetting -Scope CurrentUser

```Output
Mode : CurrentUser
ContextDirectory : C:\Users\contoso\AppData\Roaming\Windows Azure Powershell
ContextFile : AzureRmContext.json
Expand Down
8 changes: 6 additions & 2 deletions src/Accounts/Accounts/help/Get-AzDefault.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ user has set as default in the current context.
## EXAMPLES

### Example 1
```powershell
Get-AzDefault
```
PS C:\> Get-AzDefault

```Output
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup
Name : myResourceGroup
Properties : Microsoft.Azure.Management.Internal.Resources.Models.ResourceGroupProperties
Expand All @@ -37,9 +39,11 @@ Tags :
This command returns the current defaults if there are defaults set, or returns nothing if no default is set.

### Example 2
```powershell
Get-AzDefault -ResourceGroup
```
PS C:\> Get-AzDefault -ResourceGroup

```Output
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup
Name : myResourceGroup
Properties : Microsoft.Azure.Management.Internal.Resources.Models.ResourceGroupProperties
Expand Down
16 changes: 12 additions & 4 deletions src/Accounts/Accounts/help/Get-AzEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ The Get-AzEnvironment cmdlet gets endpoints and metadata for an instance of Azur

### Example 1: Getting all Azure environments
```powershell
PS C:\> Get-AzEnvironment
Get-AzEnvironment
```

```Output
Name Resource Manager Url ActiveDirectory Authority Type
---- -------------------- ------------------------- ----
AzureUSGovernment https://management.usgovcloudapi.net/ https://login.microsoftonline.us/ Built-in
Expand All @@ -37,8 +39,10 @@ This example shows how to get the endpoints and metadata for the AzureCloud (def

### Example 2: Getting the AzureCloud environment
```powershell
PS C:\> Get-AzEnvironment -Name AzureCloud
Get-AzEnvironment -Name AzureCloud
```

```Output
Name Resource Manager Url ActiveDirectory Authority Type
---- -------------------- ------------------------- ----
AzureCloud https://management.azure.com/ https://login.microsoftonline.com/ Built-in
Expand All @@ -48,8 +52,10 @@ This example shows how to get the endpoints and metadata for the AzureCloud (def

### Example 3: Getting the AzureChinaCloud environment
```powershell
PS C:\> Get-AzEnvironment -Name AzureChinaCloud | Format-List
Get-AzEnvironment -Name AzureChinaCloud | Format-List
```

```Output
Name : AzureChinaCloud
Type : Built-in
EnableAdfsAuthentication : False
Expand Down Expand Up @@ -87,8 +93,10 @@ This example shows how to get the endpoints and metadata for the AzureChinaCloud

### Example 4: Getting the AzureUSGovernment environment
```powershell
PS C:\> Get-AzEnvironment -Name AzureUSGovernment
Get-AzEnvironment -Name AzureUSGovernment
```

```Output
Name Resource Manager Url ActiveDirectory Authority Type
---- -------------------- ------------------------- ----
AzureUSGovernment https://management.usgovcloudapi.net/ https://login.microsoftonline.us/ Built-in
Expand Down
16 changes: 12 additions & 4 deletions src/Accounts/Accounts/help/Get-AzSubscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ access.
## EXAMPLES

### Example 1: Get all subscriptions in all tenants
```powershell
Get-AzSubscription
```
PS C:\>Get-AzSubscription

```Output
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Expand All @@ -46,9 +48,11 @@ This command gets all subscriptions in all tenants that are authorized for
the current account.

### Example 2: Get all subscriptions for a specific tenant
```powershell
Get-AzSubscription -TenantId "aaaa-aaaa-aaaa-aaaa"
```
PS C:\>Get-AzSubscription -TenantId "aaaa-aaaa-aaaa-aaaa"

```Output
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Expand All @@ -59,9 +63,11 @@ List all subscriptions in the given tenant that are authorized for the
current account.

### Example 3: Get all subscriptions in the current tenant
```powershell
Get-AzSubscription
```
PS C:\>Get-AzSubscription

```Output
Name Id TenantId State
---- -- -------- -----
Subscription1 yyyy-yyyy-yyyy-yyyy aaaa-aaaa-aaaa-aaaa Enabled
Expand All @@ -72,9 +78,11 @@ This command gets all subscriptions in the current tenant that are
authorized for the current user.

### Example 4: Change the current context to use a specific subscription
```powershell
Get-AzSubscription -SubscriptionId "xxxx-xxxx-xxxx-xxxx" -TenantId "yyyy-yyyy-yyyy-yyyy" | Set-AzContext
```
PS C:\>Get-AzSubscription -SubscriptionId "xxxx-xxxx-xxxx-xxxx" -TenantId "yyyy-yyyy-yyyy-yyyy" | Set-AzContext

```Output
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxx-xxxx-xxxx-xxxx) azureuser@micros... Subscription1 AzureCloud yyyy-yyyy-yyyy-yyyy
Expand Down
12 changes: 8 additions & 4 deletions src/Accounts/Accounts/help/Get-AzTenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ The Get-AzTenant cmdlet gets tenants authorized for the current user.
## EXAMPLES

### Example 1: Getting all tenants
```powershell
Connect-AzAccount
Get-AzTenant
```
PS C:\> Connect-AzAccount
PS C:\> Get-AzTenant

```Output
Id Name Category Domains
-- ----------- -------- -------
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Microsoft Home {test0.com, test1.com, test2.microsoft.com, test3.microsoft.com...}
Expand All @@ -35,10 +37,12 @@ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy Testhost Home testhost.onmicrosoft.c
This example shows how to get all of the authorized tenants of an Azure account.

### Example 2: Getting a specific tenant
```powershell
Connect-AzAccount
Get-AzTenant -TenantId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```
PS C:\> Connect-AzAccount
PS C:\> Get-AzTenant -TenantId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

```Output
Id Name Category Domains
-- ----------- -------- -------
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Microsoft Home {test0.com, test1.com, test2.microsoft.com, test3.microsoft.com...}
Expand Down
8 changes: 6 additions & 2 deletions src/Accounts/Accounts/help/Import-AzContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ Cmdlets that you run in the current session use this information to authenticate
## EXAMPLES

### Example 1: Importing a context from a AzureRmProfile
```powershell
Import-AzContext -AzContext (Connect-AzAccount)
```
PS C:\> Import-AzContext -AzContext (Connect-AzAccount)

```Output
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
[email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
Expand All @@ -42,9 +44,11 @@ [email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
This example imports a context from a PSAzureProfile that is passed through to the cmdlet.

### Example 2: Importing a context from a JSON file
```powershell
Import-AzContext -Path C:\test.json
```
PS C:\> Import-AzContext -Path C:\test.json

```Output
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
[email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
Expand Down
Loading