Skip to content

Commit 3fade8b

Browse files
author
Hovsep
committed
Merge pull request #1679 from SimonWahlin/Fix-Update-AzureRM
Update-AzureRM now only updates when need unless -Force is used
2 parents 31ae30f + c3bd49a commit 3fade8b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tools/AzureRM/AzureRM.psm1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function CheckIncompatibleVersion([bool]$Force)
6464
}
6565
}
6666

67-
function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope)
67+
function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope,[switch]$Force)
6868
{
6969
$_MinVer = "$MajorVersion.0.0.0"
7070
$_MaxVer = "$MajorVersion.9999.9999.9999"
@@ -74,7 +74,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
7474
$_ModuleAction = "installed"
7575
if ($_ExistingModule -ne $null)
7676
{
77-
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force -ErrorAction Stop
77+
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force:$force -ErrorAction Stop
7878
$_ModuleAction = "updated"
7979
}
8080
else
@@ -104,6 +104,9 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
104104
105105
.Parameter Scope
106106
Specifies the parameter scope.
107+
108+
.Parameter Force
109+
Force download and installation of modules already installed.
107110
#>
108111
function Update-AzureRM
109112
{
@@ -134,12 +137,12 @@ function Update-AzureRM
134137
{
135138
Set-PSRepository -Name $Repository -InstallationPolicy Trusted
136139

137-
Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope
138-
Install-ModuleWithVersionCheck "Azure.Storage" $MajorVersion $Repository $Scope
140+
Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope -Force:$force
141+
Install-ModuleWithVersionCheck "Azure.Storage" $MajorVersion $Repository $Scope -Force:$force
139142

140143
# Start new job
141144
$AzureRMModules | ForEach {
142-
Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope
145+
Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope -Force:$force
143146
}
144147
} finally {
145148
# Clean up

0 commit comments

Comments
 (0)