DEV Community

Bas van Ombergen
Bas van Ombergen

Posted on • Originally published at basvo.github.io on

Remove AzureRm before installing Az module

Installing the Az module on a machine that already contains AzureRm is not supported.

image-20210305203623990

There are a couple of steps needed to remove AzureRm. I will describe them below. We should first execute the following commands:

uninstall-module Azure
uninstall-module AzureRM

Enter fullscreen mode Exit fullscreen mode

Then we should check if any modules remain by using the following command:

Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}

Enter fullscreen mode Exit fullscreen mode

This will probably give a result like this:

image-20210305203939231

Remove all the remaining modules for AzureRM by using the following command:

$Modules = Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}
Foreach ($Module in $Modules) {Uninstall-Module $Module}

Enter fullscreen mode Exit fullscreen mode

Now we can try installing the Az module again:

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope CurrentUser
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)