Skip to content

Add incompatible version check #1093

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 2 commits into from
Oct 9, 2015
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
23 changes: 21 additions & 2 deletions tools/AzureRM/AzureRM.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ function Test-AdminRights([string]$Scope)
}
}

function CheckIncompatibleVersion([bool]$Force)
{
$message = "An incompatible version of Azure Resource Manager PowerShell cmdlets is installed. Please uninstall Microsoft Azure PowerShell using the 'Control Panel' before installing these cmdlets. To install these cmdlets regardless of compatibility issues, execute 'Install-AzureRM -Force'."
if ( Test-Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureResourceManager.psd1")
{
if ($Force)
{
Write-Warning $message
}
else
{
throw $message
}
}
}

function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope)
{
$_MinVer = "$MajorVersion.0.0.0"
Expand Down Expand Up @@ -81,6 +97,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
#>
function Update-AzureRM
{

param(
[Parameter(Position=0, Mandatory = $false)]
[string]
Expand All @@ -91,9 +108,12 @@ function Update-AzureRM
[Parameter(Position=2, Mandatory = $false)]
[ValidateSet("CurrentUser","AllUsers")]
[string]
$Scope = "AllUsers")
$Scope = "AllUsers",
[switch]
$Force = $false)

Test-AdminRights $Scope
CheckIncompatibleVersion($Force.IsPresent)

Write-Output "Installing AzureRM modules."

Expand Down Expand Up @@ -132,7 +152,6 @@ function Import-AzureRM
[Parameter(Position=0, Mandatory = $false)]
[string]
$MajorVersion = $AzureMajorVersion)

Write-Output "Importing AzureRM modules."

$_MinVer = "$MajorVersion.0.0.0"
Expand Down