无法安装最新的Azure PowerShell

问题描述:

我正在尝试安装最新的Azure PowerShell(2015年11月9日发布)。如果我尝试使用Web平台安装程序安装它,我得到以下错误:无法安装最新的Azure PowerShell

Azure Modules from the PowerShell Gallery are installed on this machine. Please remove these modules before installing this MSI.

如果我在PowerShell中运行Get-InstalledModule,我看到模块Azure(0.9.11版本)安装。所以我尝试使用PowerShell命令Uninstall-Module Azure进行卸载。在这里我得到以下错误:

PackageManagement\Uninstall-Package : The property 'ModuleBase' cannot be found on this object. Verify that the 
property exists. 
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSGet.psm1:1351 char:21 
+ ...  $null = PackageManagement\Uninstall-Package @PSBoundParameters 
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package], 
    Exception 
    + FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage 

好的,我解决了我的问题。愚蠢的错误:我没有作为管理员运行Uninstall-Module Azure。一旦我使用管理员权限启动PowerShell,卸载旧的Azure PowerShell就没有问题了。

嗯,希望能看到在这种情况下;-)

一个更具描述性错误消息,我打的是同样的问题,但并没有什么天青相关,当我执行Get-InstalledModule出现。

如果您在powershell提示符下执行$env:PSModulePath,它会列出您所有的模块路径位置,导航到其中的每个路径位置,并删除与a​​zure相关的任何内容,您应该能够安装新的azure powershell cmdlet。