Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Azure PowerShell?

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?

like image 640
GregGalloway Avatar asked Jan 31 '16 03:01

GregGalloway


People also ask

How do you update PowerShell?

You can update the PowerShell right from the PS cli. This command downloads the PowerShell 7.1 MSI distribution file from GitHub and then starts the installation via the MSI installer. You can also use other installation parameters: -Destination – change the default PowerShell Core installation folder.

How do I update a PowerShell module?

To specify a module to update, use the Name parameter. You can update to a module's specific version by using the RequiredVersion parameter. If an installed module is already the newest version, the module isn't updated. If the module isn't found in $env:PSModulePath , an error is displayed.

How do I update my AZ module?

To update the module, run Update-Module. Older versions of the module are not uninstalled but if you have more than one version of Az, by default module autoload and Import-Module load the latest version.


2 Answers

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.

like image 124
Jeremy Fortune Avatar answered Oct 19 '22 10:10

Jeremy Fortune


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

like image 34
Paul Hatcher Avatar answered Oct 19 '22 11:10

Paul Hatcher