Connect-AzureRmAccount : Sequence contains no elements

Connect-AzureRmAccount : Sequence contains no elements

I will get the above error message whenever I try to connect to Azure Cloud using kwyong@outlook.my (Microsoft Live Account), but i can login successfully by using my kwyong@aventistech.com account.

#Import the module into the PowerShell session
Import-Module AzureRM

#Connect to Azure with an interactive dialog for sign-in
$UserName = "kwyong@outlook.my"
"C:\Users\kwyong\Box Sync\Scripts\kwyong.txt"
$Password = Get-Content "C:\Users\kwyong\Box Sync\Scripts\Cred-AventisTech.txt" | ConvertTo-SecureString

#Specify Credential with password 
$Credential = new-object -typename System.Management.Automation.PSCredential -ArgumentList $UserName,$Password

Connect-AzureRmAccount -Credential $Credential

Solution
Thanks to https://stackoverflow.com/questions/41608217/add-azurermaccount-sequence-contains-no-elements
This is an AD restriction, you cannot login non-interactively to Azure using a Microsoft Live account.

Leave a Comment