安装特定版本的AzureRM。*模块

时间:2016-03-16 14:34:57

标签: powershell azure

我想安装所有AzureRM.*模块的特定版本,因为其中有26个我不想一个接一个地手动执行:

PS C:\Users\hyar> find-module -name azurerm.*

Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
1.0.5      AzureRM.profile                     Module     PSGallery            Microsoft Azure PowerShell - Profile ...
1.0.5      AzureRM.Storage                     Module     PSGallery            Microsoft Azure PowerShell - Storage ...
1.0.5      AzureRM.Automation                  Module     PSGallery            Microsoft Azure PowerShell - Automati...
1.0.5      AzureRM.Resources                   Module     PSGallery            Microsoft Azure PowerShell - Azure Re...
1.2.4      AzureRM.Compute                     Module     PSGallery            Microsoft Azure PowerShell - Compute ...
1.0.5      AzureRM.ApiManagement               Module     PSGallery            Microsoft Azure PowerShell - Api Mana...
1.0.5      AzureRM.Backup                      Module     PSGallery            Microsoft Azure PowerShell - Azure Ba...
1.0.5      AzureRM.Network                     Module     PSGallery            Microsoft Azure PowerShell - Network ...
1.0.6      AzureRM.HDInsight                   Module     PSGallery            Microsoft Azure PowerShell - HDInsigh...
1.0.5      AzureRM.Batch                       Module     PSGallery            Microsoft Azure PowerShell - Batch se...
1.0.5      AzureRM.DataFactories               Module     PSGallery            Microsoft Azure PowerShell - DataFact...
1.0.5      AzureRM.Insights                    Module     PSGallery            Microsoft Azure PowerShell - Insights...
1.1.4      AzureRM.SiteRecovery                Module     PSGallery            Microsoft Azure PowerShell - SiteReco...
1.0.5      AzureRM.Sql                         Module     PSGallery            Microsoft Azure PowerShell - Sql serv...
1.0.5      AzureRM.Dns                         Module     PSGallery            Microsoft Azure PowerShell - Dns serv...
1.1.3      AzureRM.RedisCache                  Module     PSGallery            Microsoft Azure PowerShell - RedisCac...
1.0.5      AzureRM.OperationalInsights         Module     PSGallery            Microsoft Azure PowerShell - Operatio...
1.1.4      AzureRM.KeyVault                    Module     PSGallery            Microsoft Azure PowerShell - KeyVault...
1.0.5      AzureRM.Websites                    Module     PSGallery            Microsoft Azure PowerShell - Websites...
1.0.5      AzureRM.Tags                        Module     PSGallery            Microsoft Azure PowerShell - Tags ser...
1.0.5      AzureRM.StreamAnalytics             Module     PSGallery            Microsoft Azure PowerShell - StreamAn...
1.0.5      AzureRM.TrafficManager              Module     PSGallery            Microsoft Azure PowerShell - TrafficM...
1.0.5      AzureRM.UsageAggregates             Module     PSGallery            Microsoft Azure PowerShell - UsageAgg...
1.0.5      AzureRM.DataLakeAnalytics           Module     PSGallery            Microsoft Azure PowerShell - Data Lak...
1.0.5      AzureRM.DataLakeStore               Module     PSGallery            Microsoft Azure PowerShell - Data Lak...
1.0.6      AzureRM.RecoveryServices            Module     PSGallery            Microsoft Azure PowerShell - Recovery...
1.0.5      AzureRM.NotificationHubs            Module     PSGallery            Microsoft Azure PowerShell - Notifica...
1.0.1      AzureRM.LogicApp                    Module     PSGallery            Microsoft Azure PowerShell - LogicApp...
0.9.2      AzureRM.AzureStackAdmin             Module     PSGallery            Microsoft Azure Stack Administration ...
0.9.3      AzureRM.AzureStackStorage           Module     PSGallery            Microsoft Azure PowerShell - Storage ...
0.7.1.1    AzureRM.Profile.Dsc                 Module     PSGallery            DSC Resources for AzureRM.Profile

所以我在那些版本大于1.0.4的模块上寻找这样的命令:

find-module -name "azurerm.*" -requiredversion 1.0.4 | install-module -force

或通过列表项执行for-each的任何其他powershell技巧

1 个答案:

答案 0 :(得分:1)

[Version] $cut = New-Object Version("1.0.4")
Find-Module -Name AzureRM.* | Where {$_.Version.CompareTo($cut) -eq 1}

这取决于Version::CompareTo