Skip to content

Commit 6f41954

Browse files
Split Az.Accounts examples (#16880)
* Update Az.Accounts examples * Restore some examples * update set-azenvironment
1 parent 2a817d7 commit 6f41954

29 files changed

+127
-72
lines changed

src/Accounts/Accounts/help/Add-AzEnvironment.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ The built-in environments AzureCloud and AzureChinaCloud target existing public
5858
## EXAMPLES
5959

6060
### Example 1: Creating and modifying a new environment
61-
```
62-
PS C:\> Add-AzEnvironment -Name TestEnvironment `
61+
```powershell
62+
Add-AzEnvironment -Name TestEnvironment `
6363
-ActiveDirectoryEndpoint TestADEndpoint `
6464
-ActiveDirectoryServiceEndpointResourceId TestADApplicationId `
6565
-ResourceManagerEndpoint TestRMEndpoint `
@@ -70,7 +70,7 @@ Name Resource Manager Url ActiveDirectory Authority
7070
---- -------------------- -------------------------
7171
TestEnvironment TestRMEndpoint TestADEndpoint/
7272
73-
PS C:\> Set-AzEnvironment -Name TestEnvironment `
73+
Set-AzEnvironment -Name TestEnvironment `
7474
-ActiveDirectoryEndpoint NewTestADEndpoint `
7575
-GraphEndpoint NewTestGraphEndpoint | Format-List
7676
@@ -110,7 +110,7 @@ BatchEndpointResourceId :
110110
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.
111111

112112
### Example 2: Discovering a new environment via Uri
113-
```
113+
```powershell
114114
<#
115115
Uri https://configuredmetadata.net returns an array of environment metadata. The following example contains a payload for the AzureCloud default environment.
116116
@@ -149,8 +149,10 @@ Uri https://configuredmetadata.net returns an array of environment metadata. The
149149
]
150150
#>
151151
152-
PS C:\> Add-AzEnvironment -AutoDiscover -Uri https://configuredmetadata.net
152+
Add-AzEnvironment -AutoDiscover -Uri https://configuredmetadata.net
153+
```
153154

155+
```Output
154156
Name Resource Manager Url ActiveDirectory Authority
155157
---- -------------------- -------------------------
156158
TestEnvironment TestRMEndpoint TestADEndpoint/

src/Accounts/Accounts/help/Clear-AzContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Remove all Azure Credentials, account, and subscription information.
2424

2525
### Example 1: Clear global context
2626
```powershell
27-
PS C:\> Clear-AzContext -Scope CurrentUser
27+
Clear-AzContext -Scope CurrentUser
2828
```
2929

3030
Remove all account, subscription, and credential information for any powershell session.

src/Accounts/Accounts/help/Clear-AzDefault.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ the user depending on the switch parameters specified by the user.
2525

2626
### Example 1
2727
```powershell
28-
PS C:\> Clear-AzDefault
28+
Clear-AzDefault
2929
```
3030

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

3333
### Example 2
3434
```powershell
35-
PS C:\> Clear-AzDefault -ResourceGroup
35+
Clear-AzDefault -ResourceGroup
3636
```
3737

3838
This command removes the default resource group set by the user in the current context.

src/Accounts/Accounts/help/Disable-AzContextAutosave.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Turn off autosaving Azure credentials. Your login information will be forgotten
2424

2525
### Example 1: Disable autosaving the context
2626
```powershell
27-
PS C:\> Disable-AzContextAutosave
27+
Disable-AzContextAutosave
2828
```
2929

3030
Disable autosave for the current user.

src/Accounts/Accounts/help/Disable-AzureRmAlias.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ Disables AzureRm prefix aliases for Az modules. If -Module is specified, only mo
2323
## EXAMPLES
2424

2525
### Example 1
26-
```
27-
PS C:\> Disable-AzureRmAlias
26+
```powershell
27+
Disable-AzureRmAlias
2828
```
2929

3030
Disables all AzureRm prefixes for the current PowerShell session.
3131

32-
### Example 1
33-
```
34-
PS C:\> Disable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
32+
### Example 2
33+
```powershell
34+
Disable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
3535
```
3636

3737
Disables AzureRm aliases for the Az.Accounts module for both the current process and for the current user.

src/Accounts/Accounts/help/Disconnect-AzAccount.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ After executing this cmdlet, you will need to login again using Connect-AzAccoun
5050

5151
### Example 1: Logout of the current account
5252
```powershell
53-
PS C:\> Disconnect-AzAccount
53+
Disconnect-AzAccount
5454
```
5555

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

5858
### Example 2: Logout of the account associated with a particular context
5959
```powershell
60-
PS C:\> Get-AzContext "Work" | Disconnect-AzAccount -Scope CurrentUser
60+
Get-AzContext "Work" | Disconnect-AzAccount -Scope CurrentUser
6161
```
6262

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

6565
### Example 3: Log out a particular user
6666
```powershell
67-
PS C:\> Disconnect-AzAccount -Username '[email protected]'
67+
Disconnect-AzAccount -Username '[email protected]'
6868
```
6969

7070
Logs out the '[email protected]' user - all credentials and all contexts associated with this user will be removed.

src/Accounts/Accounts/help/Enable-AzureRmAlias.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ Enables AzureRm prefix aliases for Az modules. If -Module is specified, only mod
2424

2525
### Example 1
2626
```powershell
27-
PS C:\> Enable-AzureRmAlias
27+
Enable-AzureRmAlias
2828
```
2929

3030
Enables all AzureRm prefixes for the current PowerShell session.
3131

3232
### Example 2
3333
```powershell
34-
PS C:\> Enable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
34+
Enable-AzureRmAlias -Module Az.Accounts -Scope CurrentUser
3535
```
3636

3737
Enables AzureRm aliases for the Az.Accounts module for both the current process and for the current user.

src/Accounts/Accounts/help/Get-AzAccessToken.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ Get access token
3131

3232
### Example 1 Get the access token for ARM endpoint
3333
```powershell
34-
PS C:\> Get-AzAccessToken
34+
Get-AzAccessToken
3535
```
3636

3737
Get access token of current account for ResourceManager endpoint
3838

3939
### Example 2 Get the access token for Microsoft Graph endpoint
4040
```powershell
41-
PS C:\> Get-AzAccessToken -ResourceTypeName MSGraph
41+
Get-AzAccessToken -ResourceTypeName MSGraph
4242
```
4343

4444
Get access token of Microsoft Graph endpoint for current account
4545

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

5151
Get access token of Microsoft Graph endpoint for current account

src/Accounts/Accounts/help/Get-AzContext.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ Azure Resource Manager cmdlets use these settings by default when making Azure R
3131
## EXAMPLES
3232

3333
### Example 1: Getting the current context
34+
```powershell
35+
Connect-AzAccount
36+
Get-AzContext
3437
```
35-
PS C:\> Connect-AzAccount
36-
PS C:\> Get-AzContext
3738

39+
```Output
3840
Name Account SubscriptionName Environment TenantId
3941
---- ------- ---------------- ----------- --------
4042
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1 AzureCloud xxxxxxxx-x...
@@ -43,9 +45,11 @@ Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1
4345
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.
4446

4547
### Example 2: Listing all available contexts
48+
```powershell
49+
Get-AzContext -ListAvailable
4650
```
47-
PS C:\> Get-AzContext -ListAvailable
4851

52+
```Output
4953
Name Account SubscriptionName Environment TenantId
5054
---- ------- ---------------- ----------- --------
5155
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... [email protected] Subscription1 AzureCloud xxxxxxxx-x...

src/Accounts/Accounts/help/Get-AzContextAutosaveSetting.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ automatically saved, and where saved context and credential information can be f
2525
## EXAMPLES
2626

2727
### Get context save metadata for the current session
28+
```powershell
29+
Get-AzContextAutosaveSetting
2830
```
29-
PS C:\> Get-AzContextAutosaveSetting
3031

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

4143
### Get context save metadata for the current user
44+
```powershell
45+
Get-AzContextAutosaveSetting -Scope CurrentUser
4246
```
43-
PS C:\> Get-AzContextAutosaveSetting -Scope CurrentUser
4447

48+
```Output
4549
Mode : CurrentUser
4650
ContextDirectory : C:\Users\contoso\AppData\Roaming\Windows Azure Powershell
4751
ContextFile : AzureRmContext.json

src/Accounts/Accounts/help/Get-AzDefault.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ user has set as default in the current context.
2323
## EXAMPLES
2424

2525
### Example 1
26+
```powershell
27+
Get-AzDefault
2628
```
27-
PS C:\> Get-AzDefault
2829

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

3941
### Example 2
42+
```powershell
43+
Get-AzDefault -ResourceGroup
4044
```
41-
PS C:\> Get-AzDefault -ResourceGroup
4245

46+
```Output
4347
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup
4448
Name : myResourceGroup
4549
Properties : Microsoft.Azure.Management.Internal.Resources.Models.ResourceGroupProperties

src/Accounts/Accounts/help/Get-AzEnvironment.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ The Get-AzEnvironment cmdlet gets endpoints and metadata for an instance of Azur
2323

2424
### Example 1: Getting all Azure environments
2525
```powershell
26-
PS C:\> Get-AzEnvironment
26+
Get-AzEnvironment
27+
```
2728

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

3840
### Example 2: Getting the AzureCloud environment
3941
```powershell
40-
PS C:\> Get-AzEnvironment -Name AzureCloud
42+
Get-AzEnvironment -Name AzureCloud
43+
```
4144

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

4953
### Example 3: Getting the AzureChinaCloud environment
5054
```powershell
51-
PS C:\> Get-AzEnvironment -Name AzureChinaCloud | Format-List
55+
Get-AzEnvironment -Name AzureChinaCloud | Format-List
56+
```
5257

58+
```Output
5359
Name : AzureChinaCloud
5460
Type : Built-in
5561
EnableAdfsAuthentication : False
@@ -87,8 +93,10 @@ This example shows how to get the endpoints and metadata for the AzureChinaCloud
8793

8894
### Example 4: Getting the AzureUSGovernment environment
8995
```powershell
90-
PS C:\> Get-AzEnvironment -Name AzureUSGovernment
96+
Get-AzEnvironment -Name AzureUSGovernment
97+
```
9198

99+
```Output
92100
Name Resource Manager Url ActiveDirectory Authority Type
93101
---- -------------------- ------------------------- ----
94102
AzureUSGovernment https://management.usgovcloudapi.net/ https://login.microsoftonline.us/ Built-in

src/Accounts/Accounts/help/Get-AzSubscription.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ access.
3232
## EXAMPLES
3333

3434
### Example 1: Get all subscriptions in all tenants
35+
```powershell
36+
Get-AzSubscription
3537
```
36-
PS C:\>Get-AzSubscription
3738

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

4850
### Example 2: Get all subscriptions for a specific tenant
51+
```powershell
52+
Get-AzSubscription -TenantId "aaaa-aaaa-aaaa-aaaa"
4953
```
50-
PS C:\>Get-AzSubscription -TenantId "aaaa-aaaa-aaaa-aaaa"
5154

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

6165
### Example 3: Get all subscriptions in the current tenant
66+
```powershell
67+
Get-AzSubscription
6268
```
63-
PS C:\>Get-AzSubscription
6469

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

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

85+
```Output
7886
Name Account SubscriptionName Environment TenantId
7987
---- ------- ---------------- ----------- --------
8088
Subscription1 (xxxx-xxxx-xxxx-xxxx) azureuser@micros... Subscription1 AzureCloud yyyy-yyyy-yyyy-yyyy

src/Accounts/Accounts/help/Get-AzTenant.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ The Get-AzTenant cmdlet gets tenants authorized for the current user.
2222
## EXAMPLES
2323

2424
### Example 1: Getting all tenants
25+
```powershell
26+
Connect-AzAccount
27+
Get-AzTenant
2528
```
26-
PS C:\> Connect-AzAccount
27-
PS C:\> Get-AzTenant
2829

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

3739
### Example 2: Getting a specific tenant
40+
```powershell
41+
Connect-AzAccount
42+
Get-AzTenant -TenantId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
3843
```
39-
PS C:\> Connect-AzAccount
40-
PS C:\> Get-AzTenant -TenantId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
4144

45+
```Output
4246
Id Name Category Domains
4347
-- ----------- -------- -------
4448
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Microsoft Home {test0.com, test1.com, test2.microsoft.com, test3.microsoft.com...}

src/Accounts/Accounts/help/Import-AzContext.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ Cmdlets that you run in the current session use this information to authenticate
3131
## EXAMPLES
3232

3333
### Example 1: Importing a context from a AzureRmProfile
34+
```powershell
35+
Import-AzContext -AzContext (Connect-AzAccount)
3436
```
35-
PS C:\> Import-AzContext -AzContext (Connect-AzAccount)
3637

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

4446
### Example 2: Importing a context from a JSON file
47+
```powershell
48+
Import-AzContext -Path C:\test.json
4549
```
46-
PS C:\> Import-AzContext -Path C:\test.json
4750

51+
```Output
4852
Account SubscriptionName TenantId Environment
4953
------- ---------------- -------- -----------
5054
[email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud

0 commit comments

Comments
 (0)