Skip to content

Update-AzureRM now only updates when need unless -Force is used #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tools/AzureRM/AzureRM.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function CheckIncompatibleVersion([bool]$Force)
}
}

function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope)
function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope,[switch]$Force)
{
$_MinVer = "$MajorVersion.0.0.0"
$_MaxVer = "$MajorVersion.9999.9999.9999"
Expand All @@ -74,7 +74,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
$_ModuleAction = "installed"
if ($_ExistingModule -ne $null)
{
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force -ErrorAction Stop
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force:$force -ErrorAction Stop
$_ModuleAction = "updated"
}
else
Expand Down Expand Up @@ -104,6 +104,9 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str

.Parameter Scope
Specifies the parameter scope.

.Parameter Force
Force download and installation of modules already installed.
#>
function Update-AzureRM
{
Expand Down Expand Up @@ -134,12 +137,12 @@ function Update-AzureRM
{
Set-PSRepository -Name $Repository -InstallationPolicy Trusted

Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope
Install-ModuleWithVersionCheck "Azure.Storage" $MajorVersion $Repository $Scope
Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope -Force:$force
Install-ModuleWithVersionCheck "Azure.Storage" $MajorVersion $Repository $Scope -Force:$force

# Start new job
$AzureRMModules | ForEach {
Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope
Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope -Force:$force
}
} finally {
# Clean up
Expand Down