1
- $AzureMajorVersion = " 0" ;
1
+ $AzureMajorVersion = " 0"
2
2
3
3
$AzureRMModules = @ (
4
4
" AzureRM.ApiManagement" ,
@@ -42,6 +42,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
42
42
{
43
43
$_MinVer = " $MajorVersion .0.0.0"
44
44
$_MaxVer = " $MajorVersion .9999.9999.9999"
45
+ $script :InstallCounter ++
45
46
try {
46
47
$_ExistingModule = Get-Module - ListAvailable - Name $Name
47
48
$_ModuleAction = " installed"
@@ -55,7 +56,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
55
56
Install-Module - Name $Name - Repository $Repository - Scope $Scope - MinimumVersion $_MinVer - MaximumVersion $_MaxVer - ErrorAction Stop
56
57
}
57
58
$v = (Get-InstalledModule - Name $Name - ErrorAction Ignore)[0 ].Version.ToString()
58
- Write-Output " $Name $v $_ModuleAction ..."
59
+ Write-Output " $Name $v $_ModuleAction [ $ script :InstallCounter / $ ( $AzureRMModules .Count + 1 ) ] ..."
59
60
} catch {
60
61
Write-Warning " Skipping $Name package..."
61
62
Write-Warning $_
@@ -96,29 +97,22 @@ function Update-AzureRM
96
97
97
98
Write-Output " Installing AzureRM modules."
98
99
99
- $_InstallationPolicy = (Get-PSRepository - Name PSGallery).InstallationPolicy
100
+ $_InstallationPolicy = (Get-PSRepository - Name $Repository ).InstallationPolicy
101
+ $script :InstallCounter = 0
100
102
101
103
try
102
104
{
103
- Set-PSRepository - Name PSGallery - InstallationPolicy Trusted
105
+ Set-PSRepository - Name $Repository - InstallationPolicy Trusted
104
106
105
107
Install-ModuleWithVersionCheck " AzureRM.Profile" $MajorVersion $Repository $Scope
106
108
107
- # Stop and remove any previous jobs
108
- $AzureRMModules | ForEach {Get-Job - Name " *$_ " } | Stop-Job | Remove-Job
109
-
110
109
# Start new job
111
- $result = $AzureRMModules | ForEach {
112
- Start-Job - Name $_ - ScriptBlock {
113
- Install-ModuleWithVersionCheck $args [0 ] $args [1 ] $args [2 ] $args [3 ]
114
- } - ArgumentList $_ , $MajorVersion , $Repository , $Scope }
115
-
116
- # Get results from the jobs
117
- $AzureRMModules | ForEach {Get-Job - Name $_ | Wait-Job | Receive-Job }
110
+ $AzureRMModules | ForEach {
111
+ Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope
112
+ }
118
113
} finally {
119
114
# Clean up
120
- Set-PSRepository - Name PSGallery - InstallationPolicy $_InstallationPolicy
121
- $AzureRMModules | ForEach {Get-Job - Name $_ | Remove-Job }
115
+ Set-PSRepository - Name $Repository - InstallationPolicy $_InstallationPolicy
122
116
}
123
117
}
124
118
0 commit comments