I recently tried to update my Azure PowerShell version and noticed that even though I had run the "Install-Module AzureRM -force -allowclobber" command, which SHOULD overwrite your current version, I was still stuck on version 3.8.0 instead of the 4.1.0 version (latest) I was trying to install. Doing a "Get-Module -Name Azure" showed BOTH versions installed.
I played with a few things, including forcibly uninstalling some of the modules under the "Azure" module, and eventually got what appeared to be a correct version running. However, when I tried to run a simple command (e.g. Get-AzureRMResourceGroup) I would receive the following error:
"Get-AzureRMResouceGroup: The Azure PowerShell session has not been properly initialized. Please import the module and try again."
After re-running the install a few times, I had an inkling that I had "something" corrupt/old that was causing these issues. I end up installing a lot of SDKs, tools, add-ins, both pre-release and RTM on my machine and something somewhere was unhappy and getting hung up. To fix this, I did the following:
- get-module azure* -list |uninstall-module
- This will uninstall all modules starting with azure*. You probably will get some red on this as there are a few order of operation dependencies. Just roll on.
- In control panel, uninstall all of the Azure related widgets which have been installed
- Repeat Step 1 to remove any final modules which may exist (in my case AzureRM.Profile).
- Install Azure PowerShell via your favorite means (WebPI, PowerShell, MSI).
After I'd 'cleaned' my installs, no more issues.