Skip to content

Commit eaa365a

Browse files
committed
Misc. fixes for install and uninstall
1 parent 034579d commit eaa365a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/AzureRM/AzureRM.psm1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
4747
$_ModuleAction = "installed"
4848
if ($_ExistingModule -ne $null)
4949
{
50-
Update-Module -Name $Name -MaximumVersion $_MaxVer -ErrorAction Stop
50+
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force -ErrorAction Stop
5151
$_ModuleAction = "updated"
5252
}
5353
else
@@ -167,11 +167,15 @@ function Uninstall-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion)
167167
$_MatchedModule = Get-InstalledModule -Name $Name -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Ignore | where {$_.Name -eq $Name}
168168
if ($_MatchedModule -ne $null) {
169169
try {
170-
Remove-Module -Name $_MatchedModule.Name -Force -ErrorAction Ignore
171-
Uninstall-Module -Name $_MatchedModule.Name -RequiredVersion $_MatchedModule.Version -Confirm:$false -ErrorAction Stop
172-
if ((Get-Module -Name $_MatchedModule.Name | where {$_.Version -eq $_MatchedModule.Version}) -eq $null)
170+
Remove-Module -Name $Name -Force -ErrorAction Ignore
171+
Uninstall-Module -Name $Name -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Confirm:$false -ErrorAction Stop
172+
if ((Get-Module -Name $Name -ListAvailable) -eq $null)
173173
{
174-
Write-Output "$Name version $($_MatchedModule.Version) uninstalled..."
174+
Write-Output "$Name uninstalled..."
175+
}
176+
else
177+
{
178+
Write-Output "$Name partially uninstalled..."
175179
}
176180
} catch {
177181
Write-Warning "Skipping $Name package..."

0 commit comments

Comments
 (0)