When developing PowerShell scripts working with Azure it's very convenient to script the login part so you are not prompted each time you tweaked the script and re-run it.
You archive this by creating a PSCredential object and passing to it your email and password (converted to a secure string first) as in a snippet below
$email='your email'
$pwd = 'your password' | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $email, $Pwd
Login-AzureRMAccount -credential $cred
You archive this by creating a PSCredential object and passing to it your email and password (converted to a secure string first) as in a snippet below
$email='your email'
$pwd = 'your password' | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $email, $Pwd
Login-AzureRMAccount -credential $cred
This works fine with corporate email addresses but if you try to use your Live ID (Hotmail or Outlook) you get back this error
Login-AzureRMAccount : Sequence contains no elements
At line:8 char:1
+ Login-AzureRMAccount -credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand
The error message is not very informative but it means that with LiveID your have to log into Azure interactively.
It might be a kind of protection against indirect brute-force attack against you your account. But it is what it is and your have to log in interactively.
Comments
Post a Comment