My Windows 11 laptop has two versions of PowerShell installed:
- 5.1.22621.963
- 7.3.1 (PowerShell Core)
Following MS instructions, I want to install the Az
module in PowerShell 7.3, so I use this command:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
This gives me the following error:
Install-Package: The following commands are already available on this system:'Login-AzAccount,Logout-AzAccount,Resolve-Error,Send-Feedback'. This module 'Az.Accounts' may override the existing commands. If you still want to install this module 'Az.Accounts', use -AllowClobber parameter
This error is discussed in this SO post. The solution given there is to remove all the pre-existing Az
modules from the PowerShell 5.x installation. This doesn't fit my situation, as (1) I don't have any Az
modules currently installed in either version of PowerShell and (2) I'm not interested in modifying my PowerShell 5.x installation. Please notice these results:
# From PowerShell 5.x
PS C:\Users\BArias> Get-InstalledModule -Name AzureRM -AllVersions -OutVariable AzVersions
Version Name Repository Description
------- ---- ---------- -----------
5.7.0 AzureRM https://www.power... Azure Resource Manager Module
And then...
# From PowerShell 7.3.x
PS C:\Users\BArias> Get-InstalledModule -Name AzureRM -AllVersions -OutVariable AzVersions
Get-Package: No match was found for the specified search criteria and module names 'AzureRM'.
I get the same "No match" result for -Name Az
. In other words, there should be no reason that I need to remove either Az
or AzureRM
from my PowerShell 7.3.x, because such things simply aren't there. Furthermore, I am complying with the MS "coexistence" rules of AzureRM
and AZ
.
So this brings me back to square one. Why am I getting the This module 'Az.Accounts' may override the existing commands
error, when my PowerShell 7.3.x does not have AzureRM
installed?
It seems like installing the Az
module into PowerShell 7.3.x is a no-brainer, so why does it not "just work?" I'm left with the impression that maybe there is something inherently incorrect with attempting to install the Az
module into PowerShell 7? For example, is MS simply expecting that I will use the "Azure Cloud Shell" and I shouldn't be fiddling with my PowerShell 7?