Skip to content

Commit c5d264b

Browse files
authored
Merge pull request MicrosoftDocs#980 from sptramer/sign-in/remove-credentials
Update sign in docs to remove -Credential for non-SP login
2 parents 9b3bb63 + 2c9151b commit c5d264b

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

docs-conceptual/azps-1.4.0/authenticate-azureps.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,10 @@ Connect-AzAccount
3030
When run, this cmdlet will present a token string. To sign in, copy this string and paste it into https://microsoft.com/devicelogin in a browser. Your PowerShell session will
3131
be authenticated to connect to Azure.
3232

33-
## Sign in with credentials
34-
35-
You can also sign in with a `PSCredential` object authorized to connect to Azure.
36-
The easiest way to get a credential object is with the [Get-Credential](/powershell/module/Microsoft.PowerShell.Security/Get-Credential) cmdlet. When run, this cmdlet will prompt you for a username/password credential pair.
37-
38-
> [!Note]
39-
> This approach doesn't work with Microsoft accounts or accounts that have two-factor authentication enabled.
40-
41-
```azurepowershell-interactive
42-
$creds = Get-Credential
43-
Connect-AzAccount -Credential $creds
44-
```
33+
> [!IMPORTANT]
34+
>
35+
> Username/password credential authorization has been removed in Azure PowerShell due to changes in Active Directory authorization implementations and security concerns.
36+
> If you use credential authorization for automation purposes, instead [create a service principal](create-azure-service-principal-azureps.md).
4537
4638
## Sign in with a service principal <a name="sp-signin"/>
4739

@@ -61,11 +53,20 @@ $pscredential = Get-Credential
6153
Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId
6254
```
6355

56+
For automation scenarios, you need to create credentials from a user name and secure string:
57+
58+
```azurepowershell-interactive
59+
$passwd = ConvertTo-SecureString <use a secure password here> -AsPlainText -Force
60+
$pscredential = New-Object System.Management.Automation.PSCredential('service principal name/id', $passwd)
61+
Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId
62+
```
63+
64+
Make sure that you use good password storage practices when automating service principal connections.
65+
6466
### Certificate-based authentication
6567

6668
Certificate-based authentication requires that Azure PowerShell can retrieve information from a local certificate
6769
store based on a certificate thumbprint.
68-
6970
```azurepowershell-interactive
7071
Connect-AzAccount -ServicePrincipal -TenantId $tenantId -CertificateThumbprint <thumbprint>
7172
```
@@ -130,4 +131,4 @@ The following command gets a list of available environments:
130131

131132
```azurepowershell-interactive
132133
Get-AzEnvironment | Select-Object Name
133-
```
134+
```

0 commit comments

Comments
 (0)