2016-03-16 5 views
4

Я хочу установить определенную версию всех AzureRM.* модулей и так как есть 26 из них я не хочу, чтобы сделать это вручную один за другим:.Установка определенной версии AzureRM * модули

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 

или любой другой Powershell трюк, который делают для-каждый по элементам списка

ответ

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

Это зависит от Version::CompareTo

Смежные вопросы