如何在没有提示的情况下登录? [英] How to Login without prompt?
问题描述
我尝试使用以下命令来获得无提示的更快的登录体验,但是每次我发现登录弹出窗口时.我什至最初尝试使用证书,但由于无法证明有效,因此尝试使用租户ID.关于如何无缝无缝登录而不是交互式登录的任何帮助或建议.
I tried following commands to get a noprompt faster login experience but each time i find login popup. I even tried using the certificate initially but since that didn't prove working, attempting with tenant id. Any help or suggestion on how to have seamless and faster login instead of interactive.
Login-AzureRmAccount -SubscriptionId 1238154XXXXfd-1c4121796e58 -TenantId 754XXXXXXXXXXX5d10d8XXX
Add-AzureRmAccount -Tenant "754XXXXXXXXXXX5d10d8XXX" -SubscriptionId "1238154XXXXfd-1c4121796e58"
Login-AzureRmAccount -TenantId 754XXXXXXXXXXX5d10d8XXX
还是我必须始终通过交互式登录提示进行操作?请求指示,并预先感谢您的考虑和时间.
Or, is it that I have to go via interactive login prompt always. Request pointers and thank in advance for consideration and time.
推荐答案
您可以使用-Credential
参数和DPAPI登录.
You can use -Credential
parameter, and DPAPI to login.
首先,运行一次以下PowerShell,以为您的帐户存储安全的密码.
First, run the following PowerShell once to store a secured password for your account.
Read-Host "Enter Password" -AsSecureString | ConvertTo-SecureString `
-AsPlainText -Force | ConvertFrom-SecureString | Out-File "C:\Password.txt"
然后,您可以使用以下脚本登录.
And then, you can use the following script to login.
# The azure account here must not be a Live ID.
$username = "<your Azure account>"
$SecurePassword = Get-Content "C:\Password.txt" | ConvertTo-SecureString
$cred = new-object -typename System.Management.Automation.PSCredential `
-argumentlist $username, $SecurePassword
Login-AzureRmAccount -Credential $cred
另一种方法是使用服务主体.首先,您应该遵循文章创建服务主体
An other way would be using Service Principal. First, you should follow the article to create a Service Principal
然后,使用以下脚本登录.
And then, use the following script to login.
$clientID = "<the client id of your AD Application>"
$key = "<the key of your AD Application>"
$SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential `
-argumentlist $clientID, $SecurePassword
$tenantID = "<the tenant id of your subscription>"
Add-AzureRmAccount -Credential $cred -TenantId $tenantID -ServicePrincipal
这篇关于如何在没有提示的情况下登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!