Closed brentarias closed 1 year ago
@brentarias , Get-InstalledModule
has some limitations. You'd better to use [Get-Module -ListAvailable
] (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_modules?view=powershell-7.3#how-to-find-installed-modules) to get module and its path.
You need to uninstall AzureRM from your environment if you want to use Az. If you hope AzureRM is on Windows PowerShell and Az is on PowerShell 7, you need to remove current Az and AzureRm and then install them for user scope https://learn.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-7.3#example-5-install-a-module-only-for-the-current-user
@mikefrobbins FYI. we may need to give more information to user.
Hi @brentarias. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve
” to remove the “issue-addressed” label and continue the conversation.
@mikefrobbins Yes, I agree with @dingmeng-xue. The MS documentation makes it clear that to obtain the Az
module, which can co-exist with the AzureRM
module, you simply install the Az
module into PowerShell Core. That is an error by omission. Instead the documentation needs to say that in order for the Az
and AzureRM
modules to co-exist, it is necessary first to uninstall AzureRM
(to erase its "AllUsers" configuration) and then instead re-install it as "CurrentUser" within Windows PowerShell. Finally, after that is fixed, then the Az
module can be installed as "CurrentUser" within PowerShell Core. Only then are both able to "co-exist".
@brentarias I'll move the following note out of the "Installation on Windows PowerShell" section of Install the Azure Az PowerShell module. The note should be in the main part of the installation instructions:
The link in that note takes you to the coexistence section of our troubleshooting article that includes the following information:
Modules installed in the all users scope of Windows PowerShell bleed over into PowerShell 7.x. This occurs because the $env:PSModulePath
in PowerShell 7 contains the Windows PowerShell all users path.
$env:PSModulePath -split [System.IO.Path]::PathSeparator
See the last two entries in the following output:
#Output from PowerShell 7.x on a Windows system
C:\Users\<userid>\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\7\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
For me, the problem was installed PowerShell Azure (5.7.1) as a .msi package. I have uninstalled PowerShell Azure from Add/Remove programs and then I was able to install new module from cli as above.
For me, the problem was installed PowerShell Azure (5.7.1) as a .msi package. I have uninstalled PowerShell Azure from Add/Remove programs and then I was able to install new module from cli as above.
Thanks!! This worked for me too! Microsoft Azure PowerShell - April 2018, 5.7.0.18831. Looks like I installed it about 2 years ago with the Storage Emulator and all that, so maybe came from Visual Studio or an Azure EXE.
### SOLUTION! Uninstall Microsoft Azure PowerShell - April 2018 (or a similar conflicting version of powershell) via Add/Remove programs, closed/opened a new admin session of PowerShell and was able to run Install-Module -Name Az. I was thinking this could have been where it was installed but it was under M for Microsoft so it got me!
Uninstalling Microsoft Azure Powershell 5x version worked for me too.. thanks.
The documentation is not clear what to do if you need to install PowerShell 7 with Az cmdlet. It only declaratively says some information around. I went step by step and still got the error state even though i read the warning.
First warning says that you cannot have both cmdlets Az and AzureRM installed in Windows PowerShell 5.1 at the same time. If I am installing PowerShell 7 the warning seems to be not relevant, because the important fact that AzureRM installed in Windows PowerShell 5.1 conflicts with the PowerShell7 version and you need to remove AzureRM from Windows PowerShell 5.1 before installing Az into PowerShell7. This is the key information that's completely missing.
I tried to uninstall the AzureRM from the Windows Power Shell with the following command under Admin rights
uninstall-module AzureRM
and install Az cmdlet in PowerShell7
Install-Module -Name Az -Repository PSGallery -Force
but this still does not help and the following error remains
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.
I found solution in this article https://basvo.github.io/azure/azurerm/powershell/2021/03/05/remove-azurerm-before-installing-az-module.html and the AzureRM can be uninstalled like that
uninstall-module Azure
uninstall-module AzureRM
$Modules = Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}
Foreach ($Module in $Modules) {Uninstall-Module $Module}
After that the Az module can be installed without an error.
It would be useful to have any recommended instructions how to solve this situation in the docs.
hell yeah! thank you mister Ninjanaut!
Description
My Windows 11 laptop has two versions of PowerShell installed:
Following MS instructions, I want to install the
Az
module in PowerShell 7.3, so I use this command:This gives me the following error:
This error is discussed in this SO post. The solution given there is to remove all the pre-existing
Az
modules from the Windows PowerShell 5.x installation. This doesn't fit my situation, as (1) I don't have anyAz
modules currently installed in either version of PowerShell and (2) I'm not interested in modifying my PowerShell 5.x installation.Digging deeper, from my PowerShell Core (7.3.x) prompt I issue the following command:
So it seems my problem is that an
AzureRM
installation in Windows PowerShell is bleeding over into my PowerShell Core installation. How do I prevent or undo this cross-wise installation, so that I can install theAz
module in PowerShell Core?Here are some additional findings:
And then...
I get the same "No match" result for
-Name Az
. In other words, there should be no reason that I need to remove eitherAz
orAzureRM
from my PowerShell 7.3.x. However, as previously stated, theAzureRM
installation within Windows PowerShell is cross-enabled inside of PowerShell Core as well. Microsoft provides instructions for havingAzureRM
andAZ
co-exist. Those instructions are useless, because they fail to account for the problem I'm presenting.So this brings me back to square one. What do I need to do to ensure that the
AzureRM
installation in Windows PowerShell stops impacting PowerShell Core? I want the scenario indicated in MS documentation, whereAzureRM
andAz
can co-exist...by having the former in Windows PowerShell only, and the latter in PowerShell Core only.For a bit more info, in my PowerShell Core I also issued this command:
I just don't get it.
Issue script & Debug output
Environment data
Module versions
Error output