diff --git a/src/ResourceManager/Profile/AzureRM.Profile.psd1 b/src/ResourceManager/Profile/AzureRM.Profile.psd1
index a417f7151faa..737e51ce6071 100644
--- a/src/ResourceManager/Profile/AzureRM.Profile.psd1
+++ b/src/ResourceManager/Profile/AzureRM.Profile.psd1
@@ -51,7 +51,7 @@ RequiredModules = @()
RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module
-ScriptsToProcess = @()
+ScriptsToProcess = @('CheckVersions.ps1')
# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @()
diff --git a/src/ResourceManager/Profile/CheckVersions.ps1 b/src/ResourceManager/Profile/CheckVersions.ps1
new file mode 100644
index 000000000000..5c2f18e6890a
--- /dev/null
+++ b/src/ResourceManager/Profile/CheckVersions.ps1
@@ -0,0 +1,63 @@
+$AzureRMModules = @(
+ "AzureRM.ApiManagement";
+ "AzureRM.Automation";
+ "AzureRM.Backup";
+ "AzureRM.Batch";
+ "AzureRM.Compute";
+ "AzureRM.DataFactories";
+ "AzureRM.Dns";
+ "AzureRM.HDInsight";
+ "AzureRM.Insights";
+ "AzureRM.KeyVault";
+ "AzureRM.Network";
+ "AzureRM.OperationalInsights";
+ "AzureRM.RedisCache";
+ "AzureRM.Resources";
+ "AzureRM.SiteRecovery";
+ "AzureRM.Sql";
+ "AzureRM.Storage";
+ "AzureRM.StreamAnalytics";
+ "AzureRM.Tags";
+ "AzureRM.TrafficManager";
+ "AzureRM.UsageAggregates";
+ "AzureRM.Websites"
+)
+
+$global:AvailableModules = @()
+
+function CheckVersions {
+ $profile = GetModuleInfo("AzureRM.Profile")
+ if (-not $profile)
+ {
+ exit 0
+ }
+ ForEach ($moduleName in $AzureRMModules) {
+ $module = GetModuleInfo($moduleName)
+ if ($module)
+ {
+ $module.RequiredModules | Where-Object {$_.Name -eq "AzureRM.Profile"} | ForEach {
+ if ($profile.Version.Major -ne $_.Version.Major) {
+ Write-Warning("$moduleName $($module.Version) is not compatible with $profile $($profile.Version)!")
+ }
+ }
+ }
+ }
+}
+
+function GetModuleInfo {
+ param(
+ [Parameter(Position=0)]
+ [string]
+ $ModuleName)
+
+ if ($global:AvailableModules.Length -eq 0)
+ {
+ $global:AvailableModules = Get-Module -ListAvailable
+ }
+
+ return $global:AvailableModules `
+ | Where-Object { $_.Name -eq $ModuleName} `
+ | Select-Object -first 1
+}
+
+CheckVersions
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj
index 7aba07db4bf8..255243591b76 100644
--- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj
+++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj
@@ -181,6 +181,7 @@
+
@@ -196,6 +197,15 @@
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
@@ -205,6 +215,9 @@
PreserveNewest
+
+ PreserveNewest
+
@@ -227,4 +240,4 @@
-
\ No newline at end of file
+
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg
new file mode 100644
index 000000000000..82c6f31f5149
Binary files /dev/null and b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg differ
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg
new file mode 100644
index 000000000000..216dc5ae07a0
Binary files /dev/null and b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg differ
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs
new file mode 100644
index 000000000000..dd3202eb7114
--- /dev/null
+++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs
@@ -0,0 +1,30 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Commands.Resources.Test.ScenarioTests;
+using Microsoft.WindowsAzure.Commands.ScenarioTest;
+using Xunit;
+
+namespace Microsoft.Azure.Commands.Profile.Test
+{
+ public class ProfileModuleTests
+ {
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void WarningOnIncompatibleVersions()
+ {
+ ProfileController.NewInstance.RunPsTest("db1ab6f0-4769-4b27-930e-01e2ef9c123c", "Test-LoadProfileModule");
+ }
+ }
+}
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1
new file mode 100644
index 000000000000..38f7b902e4a0
--- /dev/null
+++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1
@@ -0,0 +1,43 @@
+# ----------------------------------------------------------------------------------
+#
+# Copyright Microsoft Corporation
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ----------------------------------------------------------------------------------
+
+<#
+.SYNOPSIS
+Tests warning gets printed on incompatible modules with profile
+#>
+function Test-LoadProfileModule
+{
+ # Push current profile module
+ Get-PackageProvider -Name NuGet -ForceBootstrap
+ $global:pushedProfileModule = $(Get-Module AzureRM.Profile).Path
+ Remove-Module AzureRM.Profile
+ try {
+ Register-PSRepository -Name "ProfileModuleTest" -SourceLocation (Resolve-Path .\FakeModuleRepo).Path -InstallationPolicy Trusted
+ try {
+ Install-Module AzureRM.ApiManagement -Scope CurrentUser -Repository ProfileModuleTest -RequiredVersion 998.9.8
+ $global:buffer = Import-Module $global:pushedProfileModule 2>&1 3>&1 | Out-String
+ Write-Warning $global:buffer
+ Assert-True { $global:buffer -Like "*AzureRM.ApiManagement 998.9.8 is not compatible with AzureRM.Profile*" }
+ } catch [system.exception] {
+ Write-Error $_ -ErrorAction Continue
+ } finally {
+ Uninstall-Module AzureRM.ApiManagement -ErrorAction Ignore
+ Uninstall-Module AzureRM.Profile -ErrorAction Ignore
+ }
+ } catch [system.exception] {
+ Write-Error $_ -ErrorAction Continue
+ } finally {
+ Unregister-PSRepository -Name "ProfileModuleTest"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json
new file mode 100644
index 000000000000..f085c51a6519
--- /dev/null
+++ b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json
@@ -0,0 +1,5 @@
+{
+ "Entries": [],
+ "Names": {},
+ "Variables": {}
+}
\ No newline at end of file
diff --git a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj
index 0ed70994841b..fef5654ca324 100644
--- a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj
+++ b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj
@@ -169,6 +169,10 @@
AzureRM.Profile.psd1
PreserveNewest
+
+ CheckVersions.ps1
+ PreserveNewest
+
PreserveNewest