diff --git a/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 b/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 index f585526..3f974cb 100644 --- a/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 +++ b/src/ALZ/Private/Config-Helpers/Get-ALZConfig.ps1 @@ -21,10 +21,6 @@ function Get-ALZConfig { $extension = (Get-Item -Path $configFilePath).Extension.ToLower() $config = $null if ($extension -eq ".yml" -or $extension -eq ".yaml") { - if (!(Get-Module -ListAvailable -Name powershell-Yaml)) { - Write-Host "Installing YAML module" - Install-Module powershell-Yaml -Force - } try { $config = [PSCustomObject](Get-Content -Path $configFilePath | ConvertFrom-Yaml -Ordered) } catch { diff --git a/src/ALZ/Private/Tools/Test-Tooling.ps1 b/src/ALZ/Private/Tools/Test-Tooling.ps1 index 904d262..2ee9aad 100644 --- a/src/ALZ/Private/Tools/Test-Tooling.ps1 +++ b/src/ALZ/Private/Tools/Test-Tooling.ps1 @@ -175,7 +175,7 @@ function Test-Tooling { if ($null -ne $alzModuleCurrentVersion) { if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) { $checkResults += @{ - message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'." + message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-PSResource -Name ALZ'." result = "Failure" } $hasFailure = $true @@ -191,18 +191,32 @@ function Test-Tooling { # Check if powershell-yaml module is installed (only when YAML files are being used) if ($checkYamlModule.IsPresent) { Write-Verbose "Checking powershell-yaml module installation" - $yamlModule = Get-Module -ListAvailable -Name powershell-yaml + $yamlModule = Get-InstalledPSResource -Name powershell-yaml 2> $null if ($yamlModule) { $checkResults += @{ message = "powershell-yaml module is installed (version $($yamlModule.Version))." result = "Success" } } else { - $checkResults += @{ - message = "powershell-yaml module is not installed. Please install it using 'Install-Module powershell-yaml -Force'." - result = "Failure" + $installSuccessful = $false + try { + Install-PSResource powershell-yaml -TrustRepository + $installSuccessful = $true + } catch { + Write-Verbose "Failed to install powershell-yaml module" + } + if($installSuccessful) { + $checkResults += @{ + message = "powershell-yaml module was not installed, but has been successfully installed (version $((Get-InstalledPSResource -Name powershell-yaml).Version))." + result = "Success" + } + } else { + $checkResults += @{ + message = "powershell-yaml module is not installed. Please install it using 'Install-PSResource powershell-yaml'." + result = "Failure" + } + $hasFailure = $true } - $hasFailure = $true } }