From 329fa60fb5901e527427be5b3529fe0680fb525f Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Fri, 12 Dec 2025 22:09:48 +0000 Subject: [PATCH 1/2] feat: improve powershell-yaml check --- .../Private/Config-Helpers/Get-ALZConfig.ps1 | 4 --- src/ALZ/Private/Tools/Test-Tooling.ps1 | 25 +++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) 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..acd219c 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,16 +191,31 @@ 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" + } + continue + } else { + $checkResults += @{ + message = "powershell-yaml module is not installed. Please install it using 'Install-PSResource powershell-yaml'." + result = "Failure" + } } $hasFailure = $true } From 7aad63792053d01b70f6e7bb3e9260ee192076b9 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Fri, 12 Dec 2025 22:15:44 +0000 Subject: [PATCH 2/2] fix logic --- src/ALZ/Private/Tools/Test-Tooling.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ALZ/Private/Tools/Test-Tooling.ps1 b/src/ALZ/Private/Tools/Test-Tooling.ps1 index acd219c..2ee9aad 100644 --- a/src/ALZ/Private/Tools/Test-Tooling.ps1 +++ b/src/ALZ/Private/Tools/Test-Tooling.ps1 @@ -210,14 +210,13 @@ function Test-Tooling { message = "powershell-yaml module was not installed, but has been successfully installed (version $((Get-InstalledPSResource -Name powershell-yaml).Version))." result = "Success" } - continue } else { $checkResults += @{ message = "powershell-yaml module is not installed. Please install it using 'Install-PSResource powershell-yaml'." result = "Failure" } + $hasFailure = $true } - $hasFailure = $true } }