Skip to content

Commit 91cb2af

Browse files
authored
Updated service principal example for automation (MicrosoftDocs#1937)
1 parent 4e4cc6b commit 91cb2af

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

azps-6.4.0/Az.Accounts/Connect-AzAccount.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,14 @@ azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
122122

123123
### Example 3: Connect to Azure using a service principal account
124124

125-
The first command prompts for service principal credentials and stores them in the `$Credential`
126-
variable. Enter your application ID for the username and service principal secret as the password
127-
when prompted. The second command connects the specified Azure tenant using the service principal
128-
credentials stored in the `$Credential` variable. The **ServicePrincipal** switch parameter
129-
indicates that the account authenticates as a service principal.
125+
The first command stores the service principal credentials in the `$Credential` variable. The second
126+
command connects the specified Azure tenant using the service principal credentials stored in the
127+
`$Credential` variable. The **ServicePrincipal** switch parameter indicates that the account
128+
authenticates as a service principal.
130129

131130
```powershell
132-
$Credential = Get-Credential
133-
Connect-AzAccount -Credential $Credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -ServicePrincipal
131+
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $SecuredPassword
132+
Connect-AzAccount -ServicePrincipal -TenantId $TenantId -Credential $Credential
134133
```
135134

136135
```Output

azps-6.5.0/Az.Accounts/Connect-AzAccount.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,14 @@ azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
122122

123123
### Example 3: Connect to Azure using a service principal account
124124

125-
The first command prompts for service principal credentials and stores them in the `$Credential`
126-
variable. Enter your application ID for the username and service principal secret as the password
127-
when prompted. The second command connects the specified Azure tenant using the service principal
128-
credentials stored in the `$Credential` variable. The **ServicePrincipal** switch parameter
129-
indicates that the account authenticates as a service principal.
125+
The first command stores the service principal credentials in the `$Credential` variable. The second
126+
command connects the specified Azure tenant using the service principal credentials stored in the
127+
`$Credential` variable. The **ServicePrincipal** switch parameter indicates that the account
128+
authenticates as a service principal.
130129

131130
```powershell
132-
$Credential = Get-Credential
133-
Connect-AzAccount -Credential $Credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -ServicePrincipal
131+
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $SecuredPassword
132+
Connect-AzAccount -ServicePrincipal -TenantId $TenantId -Credential $Credential
134133
```
135134

136135
```Output

0 commit comments

Comments
 (0)