14

I have Azure PowerShell 1.0.3 installed via the Gallery (per the instructions here in the Installing Azure PowerShell From The Gallery section). I want to update to the latest version but am unclear on the commands that I need to run. I tried the following, but decided to ask rather than potentially corrupt my installation:

PS C:\Windows\system32> Install-Module AzureRM

You are installing the module(s) from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install software from 'https://www.powershellgallery.com/api/v2/'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
WARNING: Version '1.0.3' of module 'AzureRM' is already installed at 'C:\Program
Files\WindowsPowerShell\Modules\AzureRM\1.0.3'. To delete version '1.0.3' and install version '1.1.0', run
Install-Module, and add the -Force parameter.

Can someone provide a script to update Azure PowerShell?

5 Answers 5

17

The command you need to run is in the help text you posted. Use Install-Module -Force AzureRM. See the -Force tag.

Once you've updated the bootstrapper, run Install-AzureRM to install the new packages.

Edit for updated (WMF > 4) PowerShell:

PowerShell has an Update-Module AzureRM function that will perform similar activity as Install-Module -Force AzureRM. You may also want to use the -AllowClobber argument on Install-Module if you have functions already defined in your local environment that the AzureRM would overwrite.

However, neither will update your current environment, so prior to running Install-AzureRM, check to see that you've loaded the latest AzureRM module. For example, if you wanted to update from 1.0.1 to 1.0.3:

$ Get-Module AzureRM

ModuleType Version    Name         ExportedCommands
---------- -------    ----         ----------------
Script     1.0.1      AzureRM      {...}

$ Update-Module AzureRM

$ # This will still be old because we haven't imported the newer version.
$ (Get-Module AzureRM).Version.ToString() 
1.0.1

$ Remove-Module AzureRM
$ Import-Module AzureRM
$ (Get-Module AzureRM).Version.ToString() 
1.0.3

$ Install-AzureRM

Or you can just open a new PowerShell window after running the update.

3
  • Is that it? There are about 6 commands in the full install script at the link I provided. Do any others need to be run? Commented Jan 31, 2016 at 5:56
  • A lot of those commands have to do with importing the module as you're about to use it. You'll likely need to continue to do that, but yes, that's all you need to do. You can verify it with Get-Module AzureRM. Commented Jan 31, 2016 at 5:58
  • Actually, you should probably run Install-AzureRM again once you've refreshed the bootstrapper. Good point. I'll update the answer. Commented Jan 31, 2016 at 6:01
10

It appears the command has changed a bit, I had to use Install-Module -Force AzureRM -AllowClobber to get it to update

1

The most reliable way appears to be:

Download the latest MSI and run it. https://github.com/Azure/azure-powershell/releases

I know you asked for a scripted version... I did not find the various script answers satisfactory. (I didn't want a side-by-side install; Install-AzureRM wasn't found; etc).

1
  • 1
    I tried every other command listed in answer in this SO post, but none of these works so I just downloaded and installed the latest version using MSI. :(
    – RSW
    Commented Jan 14, 2023 at 6:00
0

Best and easy way is from the official link and look for the highlighted. The link will give you MSI of the latest version of AzurePowershell

enter image description here

0
0

I use :

$azureRMs = Get-Module
foreach($azureRM in $azureRMs)
    {
    if($azureRM.name -like "AzureRM*" )
        {
        write-host "removing" $azureRM
        remove-Module -Name $azureRM
        Uninstall-Module -Name $azureRM
        }
    }
Install-Module azureRM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.