Mar*_*lic 4 powershell azure azure-powershell
我正在尝试验证脚本以通过PowerShell连接到Azure.
$username = "asdfasdf"
$password = "asdfasdf"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureRmAccount -Credential $cred
Select-AzureRmSubscription -SubscriptionId asdfasdf
Run Code Online (Sandbox Code Playgroud)
完整的错误消息:
Add-AzureRmAccount : Sequence contains no elements
At C:\Users\Martin\Documents\Tasks\Azure Script ARM API Syntax Conversion\Connect Azure V1.ps1:6 char:1
+ Add-AzureRmAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand
Run Code Online (Sandbox Code Playgroud)
我在这里看到Login-AzureRmAccount无法使用PSCredential登录Azure,也许特殊字符可能会导致错误,但我尝试!在密码中转义,但没有成功.还有什么可能导致这个问题?
| 归档时间: |
|
| 查看次数: |
2985 次 |
| 最近记录: |