如何更新Azure PowerShell?
我已通过Gallery安装了Azure PowerShell 1.0.3(按照Gallery部分安装Azure PowerShell中的说明)。我想更新到最新版本,但不清楚需要运行哪些命令。我尝试了以下操作,但决定询问,而不是可能损坏我的安装:如何更新Azure PowerShell?,azure,azure-powershell,Azure,Azure Powershell,我已通过Gallery安装了Azure PowerShell 1.0.3(按照Gallery部分安装Azure PowerShell中的说明)。我想更新到最新版本,但不清楚需要运行哪些命令。我尝试了以下操作,但决定询问,而不是可能损坏我的安装: PS C:\Windows\system32> Install-Module AzureRM You are installing the module(s) from an untrusted repository. If you trust
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.
有人能提供一个脚本来更新Azure PowerShell吗?您需要运行的命令在您发布的帮助文本中。使用
安装模块-Force AzureRM
更新引导程序后,运行Install AzureRM
安装新软件包
编辑已更新(WMF>4)的PowerShell:
PowerShell具有一个更新模块AzureRM
功能,该功能将执行与安装模块-强制AzureRM
类似的活动。如果您的本地环境中已经定义了AzureRM将覆盖的函数,那么您可能还希望在安装模块上使用-AllowClobber
参数
但是,两者都不会更新当前环境,因此在运行安装AzureRM
之前,请检查是否已加载最新的AzureRM模块。例如,如果要从1.0.1更新到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
或者,您可以在运行更新后打开一个新的PowerShell窗口。命令似乎有点变化,我必须使用
安装模块-Force AzureRM-AllowClobber
使其更新最好且简单的方法是从中查找突出显示的。
该链接将为您提供AzurePowershell最新版本的MSI
最可靠的方法似乎是: 下载最新的MSI并运行它 我知道你要的是脚本版本。。。我觉得各种剧本的答案并不令人满意。(我不想并行安装;
未找到install AzureRM
等)。我使用:
$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
是这样吗?在我提供的链接中,完整安装脚本中大约有6个命令。需要运行其他命令吗?这些命令中有很多都与在您即将使用模块时导入模块有关。你可能需要继续这样做,但是的,这就是你需要做的。您可以使用
Get Module AzureRM
进行验证。实际上,在刷新引导程序后,您可能应该再次运行Install AzureRM。说得好。我会更新答案。