Skip to content

Commit c2ef6f8

Browse files
committed
Throwing if no Az module is available at all
1 parent 7bae31b commit c2ef6f8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

AutomatedLab/AutomatedLabAzure.psm1

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ function Test-LabAzureModuleAvailability
1414
$moduleManifest = Get-ChildItem -Path $paths -File -Filter *.psd1 -Recurse -Force -ErrorAction SilentlyContinue |
1515
Sort-Object -Property { Split-Path $_.DirectoryName -Leaf } -Descending |
1616
Select-Object -First 1
17-
$availableVersion = [version](Split-Path -Path $moduleManifest.DirectoryName -Leaf)
1817

18+
if (-not $moduleManifest)
19+
{
20+
Stop-PSFFunction -Message "The Azure PowerShell module version $($minimumAzureModuleVersion) or greater is not available.`r`nPlease remove all old versions of Az and AzureRM, and reinstall using Install-Module Az" -EnableException $true
21+
return $false
22+
}
23+
24+
$availableVersion = [version](Split-Path -Path $moduleManifest.DirectoryName -Leaf)
1925
if ($availableVersion -lt $minimumAzureModuleVersion)
2026
{
2127
Stop-PSFFunction -Message "The Azure PowerShell module version $($minimumAzureModuleVersion) or greater is not available.`r`nPlease remove all old versions of Az and AzureRM, and reinstall using Install-Module Az" -EnableException $true

0 commit comments

Comments
 (0)