Trying to Log in to Azure in Powershell

azure powershell select subscription
connect to azure powershell
azure powershell commands
connect to azure ad powershell
azure powershell list subscriptions
azure rm powershell

I am following the MS guide located here and everything goes through correctly until I have to actually log in. The pop up window appears for my creds and validates them, but powershell doesn't seem to notice.

So it goes Install Module, Import Module, Verify Version, Log in. See below for what happens on the last two steps.

PS C:\WINDOWS\system32> Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path

Name    Version Path
----    ------- ----
AzureRM 6.3.0   C:\Program Files\WindowsPowerShell\Modules\AzureRM\6.3.0\AzureRM.psd1

PS C:\WINDOWS\system32> Connect-AzureRmAccount

Account          :
SubscriptionName :
SubscriptionId   :
TenantId         :
Environment      :

PS C:\WINDOWS\system32>

Of course, this prevents me from doing very much else with Azure from that point forward.

Edit: Issue appears on multiple workstations

I got this same issue. I have two users like many of you: the Azure user that is the "Work" account, and then the "Personal" account which is also created automatically by Office365 and Azure. I was getting the issue when I tried to use my "personal" account, in which I have some subscriptions added (delegated).

After trying lots, what worked for me was to login to the "Work" account when the "Connect-AzureRmAccount" command asks for an username/password. Then, I again use the command "Connect-AzureRMAccount", but this time I entered the personal account, and it finally worked.

Picture here

Edit: A better way I found later was this, as I manage a lot of subscriptions/tenants from a single account (delegated access):

Put the "tenantid" into a variable (you can get this ID on the Azure Portal, in my case, on the option to change directories):

How to get your tenant's IDs quickly

$tenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Login specifying the TenantId: Login-AzureRmAccount -TenantId $tenantId

Example 2

Connect to Exchange Online PowerShell, I got this same issue. I have two users like many of you: the Azure user that is the "Work" account, and then the "Personal" account which is also  Azure PowerShell supports several authentication methods. The easiest way to get started is with Azure Cloud Shell , which automatically logs you in. With a local install, you can sign in interactively through your browser.

You can try this...

Install-Module PoweshellGet -Force

Set-ExecutionPolicy -ExicutionPolicy Remotesigned 

Install-Module AzureRm

Import-Module -Name AzureRm

Connect-AzureRmAccount (AzureRM.Profile), How To Connect to Microsoft Azure with PowerShell. Installing the Azure PowerShell Module. To get started, you'll need to download and install the Azure PowerShell module. Connecting Your Azure Subscription. After you've gotten the Azure module installed, open up your PowerShell console and type Add-AzureAccount. Azure PowerShell is designed for managing and administering Azure resources from the command line. Use Azure PowerShell when you want to build automated tools that use the Azure Resource Manager model. Try it out in your browser with Azure Cloud Shell, or install on your local machine. This article helps you get started with Azure PowerShell

You can use the below link to install latest PowerShell version:

And then use something like this in order to automatically pass in the username password, and skipping the UI:

$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force

$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)

Login-AzureRmAccount -Credential $psCred

Trying to Log in to Azure in Powershell, Login-AzAccount , Add-AzAccount or Connect-AzAccount , there appears to be a lot of different ways to authenticate to an Azure subscription if  My parameters file is above - replace all the nulls with the appropriate values (use the template's default values as guides), and you can try a deploy. Open PowerShell and run deploy.ps1: The script asks for your subscription ID, and the resource group name you want to deploy to, then it opens an Azure login dialogue.

Have you tried the following:

Import-Module Microsoft.Powershell.Security

$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)

$decrypt = $psCred.GetNetworkCredential()
$ptpass = $decrypt.Password
Write-Output "Logging in to Azure using $azureAccountName with a password of $ptpass"

Login-AzureRmAccount -Credential $psCred

If you receive an error with this code, please comment with the entire error message.

How To Connect to Microsoft Azure with PowerShell , This requires that you have an Azure subscription. Of course, the main reason you need to sign in isn't because Microsoft just wants to know  I've now updated the post with the updated commands. Note you should update your version of the Azure Command Line Tools before configuring this on your own machine. I’ve been working in Azure for a while and find it quite frustrating that every time I launched up PowerShell ISE I needed to first log into Azure to get things started.

The only thing i can think of is the below

You maybe using Azure Service Management (Azure V1 / Azure Classic) which uses a different module to Azure Resource Manager (ARM , Azure V2).

To install Azure Service Management Module: Install-Module Azure -AllowClobber Allowing clobber because you already have AzureRM Module installed

Import Azure Module to PowerShell: Import-Module Azure

Logs into ASM: Add-AzureAccount

Shows you all subscriptions Get-AzureSubscriptions

Selects the Subscription you allocate to work within Select-AzureSubscription

Answered something similar in the below Thread: Login-AzureRmAccount return subscription but Get-AzureSubscription return empty

Hope this helps

Connect-AzAccount: Your Gateway To Azure with PowerShell, Below I will share with you how I login to Azure via the 'Az' PowerShell module every time without fail to avoid access issues. Open an In-Private  In-Depth. How To Connect to Microsoft Azure with PowerShell. Bypassing the Azure Portal and going straight to PowerShell will provide you with more options for managing Microsoft's cloud.

Auto login to Azure with PowerShell – 4sysops, I even tried specifying the tenant ID of the partner when I get the tokens but still the same error when I use the Az command for login. Have you  There are two ways you can connect to Azure services: Connect to ARM using the Azure RM modules. Connect to Azure AD using the Azure AD module. How to connect to Azure ARM: Connecting to ARM allows you to deploy and manage VMs via PowerShell cmdlets, manage storage, create Resource Groups and so on.

Logging In To Azure PowerShell, Actually, I tried the below commands inorder to get a no-prompt login First, run the following PowerShell once to store a secured password for  Login via PowerShell; Set the current subscription context; Once you complete the above, you will have set the current azure subscription context. Login via PowerShell. I like to use the Windows PowerShell ISE console app because I find it more friendly, but choose you own approach. Enter the following command to login your PowerShell to Azure

Azure/azure-powershell, Sign in with Azure AD administrator credentials. Run command Import-Module MSOnline. You can now run a number of PowerShell cmdlets to  Open “Microsoft Azure PowerShell” console in an elevated state. Type the following command: Get-AzurePublishSettingsFile. This will prompt you to enter login details for your Azure subscription account. Once you have logged in you have successfully connected PowerShell to Azure.