Azure PowerShell Login Issue

Introduction

At times we face issues while logging in to Azure PowerShell. There may be different types of error messages while logging in. This article explains about the resolution of the error message “The PowerShell session has not been properly initialized. Please import the module and try again."

Azure PowerShell

This error message appears in certain cases like, the module is not installed/imported successfully or the Windows PowerShell is not updated successfully. The below steps helps to resolve this issue.

Troubleshooting

Step1

Check the PowerShell Version by executing the below command,

Get-Host

Or

$PSVersionTable

Azure PowerShell

Step2

Verify the PowerShell module list to understand the list of Azure PowerShell module installed\imported.

Azure PowerShell

The AzureRm.Profile is an important module using which the latest Azure resources can be managed through the PowerShell. Here the AzureRM Module is not installed/Imported.

In order to rectify the issue, the existing Azure PowerShell module(s) should be clean wiped and to be reinstalled.

Step3

Check the Azure PowerShell module directory location by executing the following command

Get-Module AzureRM –ListAvailable| Select-Object Name,Version,Path

Azure PowerShell

Here we notice that the earlier version of Azure PowerShell Module is installed. Note the path of Azure PowerShell module.

Change the PowerShell Session to the Azure Module path by executing the following command.

Cd “C:\Program Files\WindowsPowerShell\Modules\AzureRM\4.0.2\”

Azure PowerShell

Step4

Execute the below Command to uninstall the existing Azure PowerShell module.

Get-Module azure* -ListAvailable | Uninstall-Module

Azure PowerShell

This command uninstalls all the Azure related PowerShell modules.

If any of the Azure module(s) is not uninstalled, change the PowerShell session to different path and execute the command once again.

Step 5

Verify whether the Azure PowerShell module(s) are uninstalled successfully by executing the below command.

Get-Module

Azure PowerShell

Step6

Follow the steps mentioned in my previous article to install and import the Azure PowerShell module.


Similar Articles