From ddd00c4e105bab53094006a8b6e22e14321cd299 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 28 Sep 2015 23:00:12 -0700 Subject: [PATCH 1/7] [fixes #103630362] Add version check scripts to Profile module --- .../Profile/AzureRM.Profile.psd1 | 2 +- src/ResourceManager/Profile/CheckVersions.ps1 | 56 +++++++++++++++++++ .../Commands.Profile/Commands.Profile.csproj | 4 ++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/ResourceManager/Profile/CheckVersions.ps1 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..607ffe5985b4 --- /dev/null +++ b/src/ResourceManager/Profile/CheckVersions.ps1 @@ -0,0 +1,56 @@ +$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" +) + +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) + + return Get-Module -ListAvailable ` + | Where-Object { $_.Name -eq $ModuleName} ` + | Select-Object -first 1 +} + +CheckVersions diff --git a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj index 252b19eee0c4..5ce987267b50 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj +++ b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj @@ -167,6 +167,10 @@ AzureRM.Profile.psd1 PreserveNewest + + CheckVersions.ps1 + PreserveNewest + PreserveNewest From 59172d70aa7c30d22d39709725ffaeabb15c23b4 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Tue, 29 Sep 2015 16:13:21 -0700 Subject: [PATCH 2/7] Add tests on Profile module version check --- src/ResourceManager/Profile/CheckVersions.ps1 | 9 ++++- .../Commands.Profile.Test.csproj | 12 ++++++- .../AzureRM.ApiManagement.998.9.8.nupkg | Bin 0 -> 3719 bytes .../AzureRM.Profile.999.9.8.nupkg | Bin 0 -> 4545 bytes .../ProfileModuleTests.cs | 30 ++++++++++++++++ .../ProfileModuleTests.ps1 | 34 ++++++++++++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.ApiManagement.998.9.8.nupkg create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.Profile.999.9.8.nupkg create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 diff --git a/src/ResourceManager/Profile/CheckVersions.ps1 b/src/ResourceManager/Profile/CheckVersions.ps1 index 607ffe5985b4..1a8348a178b2 100644 --- a/src/ResourceManager/Profile/CheckVersions.ps1 +++ b/src/ResourceManager/Profile/CheckVersions.ps1 @@ -23,6 +23,8 @@ $AzureRMModules = @( "AzureRM.Websites" ) +$AvailableModules = @() + function CheckVersions { $profile = GetModuleInfo("AzureRM.Profile") if (-not $profile) @@ -48,7 +50,12 @@ function GetModuleInfo { [string] $ModuleName) - return Get-Module -ListAvailable ` + if ($global:AvailableModules.Length -eq 0) + { + $global:AvailableModules = Get-Module -ListAvailable + } + + return $global:AvailableModules ` | Where-Object { $_.Name -eq $ModuleName} ` | Select-Object -first 1 } 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 eb66b4cb1a67..24ab48407989 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -180,6 +180,7 @@ + @@ -193,12 +194,21 @@ + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + @@ -221,4 +231,4 @@ - \ No newline at end of file + diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.ApiManagement.998.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.ApiManagement.998.9.8.nupkg new file mode 100644 index 0000000000000000000000000000000000000000..82c6f31f5149f066a0b85a0fbe4dcf2e8cf8c3e8 GIT binary patch literal 3719 zcmb`K30Tu;8h{H*xkT_r@Ca356q>Y!LJKVj2#8qZ6b~3IX$pll?IbPt!UL|1=YZpZ zqOzh3xC$tWuA&YK4hXAw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Kdr9p*24;SbNcYx6LX5+_FfqahM{Jp1rIxjS|;#^(_y7RaA%<8=-{Y!S0v@$mKpWhZ%8s0&Lv9C|C z-{c*9<;iSv_*?Rwi~q@N@H!qu&G#w{vq>XoKa0Igt!yx;`zgTl{$Q_7_+)6 z&R5H1`JNlH>gPX%sv^zXV~m??tv04MGhACzy|p6NbR`^e+%yUnB z1V{a@Ke;fwB5>x{&zyTK5@at=y$&|aaH0jxnB=zq2==n+bs#9!+^#M7S^eeXHtp?hwk zMaTZ2J!S07Ea+M1MBP(c{pM}{W}&0Nc-fVilaAgfZ}TYY_(fY;j>C<0b=Av%6cD?j z^6(}0#xK5Sf0_2IY%)GWJ?2Aywim!d4OOPV#HxlYfFVSz>WMf+2k8)HNLG$ulHs1N zuAq7{BpHi~hRnvq#DFo@D#JvFr$eiF%l%a_Koz05oR7lDp#33@zsd?@wogZn0JeuQ zgfEw3j=Yb20JusqnG{pu1qV`-P)Z9B9L7X4CBCR>sCpdWBaJ~Y{|H1Z2B-kR48Sln zsO+fgDs71b1Wt&AA_Q|BwMnX!)Py*LWaY?avp_b;;y@p7aH5d77%3*e9ewZJ~D z5K8nOhFwcyyebMC#l=T79n*;vmLmk=5{x>Ewh{zB6X1W*{Q!+)dj8DtMo{h003p?a z5ZR!iNhJ;E!>8{jBVR+*-d2=~PNcEObpD_wKwO=O9eLCe9E5#6l2VF9(jXa=v^U#U zXurRyF|*wLvieos+n?b}-CGTTWTSgiu7J8P)V<%8O!(T+Y`s|hI&w-r?JTNL2T!ZD mNngItjCB8Lg{r&HAeL>EdiC+rA}htTh;JQH*4Y!3|Na0b9%ozt literal 0 HcmV?d00001 diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.Profile.999.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.Profile.999.9.8.nupkg new file mode 100644 index 0000000000000000000000000000000000000000..216dc5ae07a0614162ffc47d99dd920be324dfba GIT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ZTykz9@r2tWgT zz6yQvl_5Thwr>t1hNLjA`f&C36>B*g{*HtH!S??!?Negkbox6hGfXOeSsOqROFWTA zC{YOmsWepX4_Ebr#DAaRx8&YnLpDxghV2&p+Icv}P%$zXqYgiLhGWQsF&tqiX&Q_W zOeFl3LJgn&(1UKUx%@Qz$B(_?!w;?F!NX^cCw#4{UAQVZJ0uWB;s1+x@wckW-~J8h CmC8u~ literal 0 HcmV?d00001 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..27ef30bf3302 --- /dev/null +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 @@ -0,0 +1,34 @@ +# ---------------------------------------------------------------------------------- +# +# 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 each of the major parts of retrieving subscriptions in ARM mode +#> +function Test-LoadProfileModule +{ + try { + Register-PSRepository -Name "ProfileModuleTest" -SourceLocation (Resolve-Path .\).Path -InstallationPolicy Trusted + try { + Install-Module AzureRM.ApiManagement -Scope CurrentUser -Repository ProfileModuleTest -RequiredVersion 998.9.8 + $buffer = Import-Module AzureRM.Profile 2>&1 3>&1 | Out-String + } finally { + Uninstall-Module AzureRM.ApiManagement -ErrorAction Ignore + Uninstall-Module AzureRM.Profile -ErrorAction Ignore + } + } finally { + Unregister-PSRepository -Name "ProfileModuleTest" + } + Assert-True { $buffer -Like "*AzureRM.ApiManagement 998.9.8 is not compatible with AzureRM.Profile*" } +} \ No newline at end of file From 83d33b1a01e0aa7b11eb70fb511733712d52081f Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 2 Oct 2015 16:16:09 -0700 Subject: [PATCH 3/7] Fix test on checking profile versions --- src/ResourceManager/Profile/CheckVersions.ps1 | 2 +- .../Commands.Profile.Test.csproj | 6 +++--- .../AzureRM.ApiManagement.998.9.8.nupkg | Bin .../AzureRM.Profile.999.9.8.nupkg | Bin .../Commands.Profile.Test/ProfileModuleTests.ps1 | 10 +++++++--- 5 files changed, 11 insertions(+), 7 deletions(-) rename src/ResourceManager/Profile/Commands.Profile.Test/{ProfileModuleTestRepo => FakeModuleRepo}/AzureRM.ApiManagement.998.9.8.nupkg (100%) rename src/ResourceManager/Profile/Commands.Profile.Test/{ProfileModuleTestRepo => FakeModuleRepo}/AzureRM.Profile.999.9.8.nupkg (100%) diff --git a/src/ResourceManager/Profile/CheckVersions.ps1 b/src/ResourceManager/Profile/CheckVersions.ps1 index 1a8348a178b2..5c2f18e6890a 100644 --- a/src/ResourceManager/Profile/CheckVersions.ps1 +++ b/src/ResourceManager/Profile/CheckVersions.ps1 @@ -23,7 +23,7 @@ $AzureRMModules = @( "AzureRM.Websites" ) -$AvailableModules = @() +$global:AvailableModules = @() function CheckVersions { $profile = GetModuleInfo("AzureRM.Profile") 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 24ab48407989..28b82550367c 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -194,10 +194,10 @@ - + PreserveNewest - + PreserveNewest @@ -231,4 +231,4 @@ - + \ No newline at end of file diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.ApiManagement.998.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg similarity index 100% rename from src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.ApiManagement.998.9.8.nupkg rename to src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.Profile.999.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg similarity index 100% rename from src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTestRepo/AzureRM.Profile.999.9.8.nupkg rename to src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 index 27ef30bf3302..d9a00248d6bf 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 @@ -14,15 +14,20 @@ <# .SYNOPSIS -Tests each of the major parts of retrieving subscriptions in ARM mode +Tests warning gets printed on incompatible modules with profile #> function Test-LoadProfileModule { + # Push current profile module + $global:pushedProfileModule = $(Get-Module AzureRM.Profile).Path + Remove-Module AzureRM.Profile try { Register-PSRepository -Name "ProfileModuleTest" -SourceLocation (Resolve-Path .\).Path -InstallationPolicy Trusted try { Install-Module AzureRM.ApiManagement -Scope CurrentUser -Repository ProfileModuleTest -RequiredVersion 998.9.8 - $buffer = Import-Module AzureRM.Profile 2>&1 3>&1 | Out-String + $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*" } } finally { Uninstall-Module AzureRM.ApiManagement -ErrorAction Ignore Uninstall-Module AzureRM.Profile -ErrorAction Ignore @@ -30,5 +35,4 @@ function Test-LoadProfileModule } finally { Unregister-PSRepository -Name "ProfileModuleTest" } - Assert-True { $buffer -Like "*AzureRM.ApiManagement 998.9.8 is not compatible with AzureRM.Profile*" } } \ No newline at end of file From 81dbb31b02dccdad66045aab2bee085ac43e3dc3 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 5 Oct 2015 10:36:27 -0700 Subject: [PATCH 4/7] Add dummy session record --- .../WarningOnIncompatibleVersions.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json 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 From 5d597323172bf689c6e9ad6864c07242e0766c0c Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 5 Oct 2015 12:50:04 -0700 Subject: [PATCH 5/7] Save all --- .../Profile/Commands.Profile.Test/Commands.Profile.Test.csproj | 3 +++ 1 file changed, 3 insertions(+) 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 28b82550367c..f13809b8c174 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -200,6 +200,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 392af204f53205b32978791891901bf0762fcad2 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Tue, 6 Oct 2015 12:07:23 -0700 Subject: [PATCH 6/7] Print inner exceptions for profile module test --- .../Profile/Commands.Profile.Test/ProfileModuleTests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 index d9a00248d6bf..5d8f02db353e 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 @@ -22,16 +22,20 @@ function Test-LoadProfileModule $global:pushedProfileModule = $(Get-Module AzureRM.Profile).Path Remove-Module AzureRM.Profile try { - Register-PSRepository -Name "ProfileModuleTest" -SourceLocation (Resolve-Path .\).Path -InstallationPolicy Trusted + 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" } From 710ff46ff1c1ed5c4fe4f6edcf3b0b314324e04d Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Tue, 6 Oct 2015 16:54:26 -0700 Subject: [PATCH 7/7] Add nuget bootstrap to profile module test --- .../Profile/Commands.Profile.Test/ProfileModuleTests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 index 5d8f02db353e..38f7b902e4a0 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 @@ -19,6 +19,7 @@ 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 {