From 092ae26257c1c32512057e3cda5f5c8207f68993 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Thu, 29 May 2025 16:59:45 -0700 Subject: [PATCH] Add dynamic SKU handling for Windows releases and update UI integration - Introduced a new function `Get-AvailableSkusForRelease` to retrieve available SKUs based on the selected Windows release value. - Added a new function `Update-WindowsSkuCombo` to refresh the SKU ComboBox in the UI when the release changes. - Updated the SKU lists for various Windows versions, including client and server SKUs, as well as LTSC editions. - Modified the `RefreshWindowsSettingsCombos` function to call the new SKU update function. - Ensured that the SKU ComboBox is populated dynamically based on the selected release, improving user experience and accuracy. --- FFUDevelopment/BuildFFUVM_UI.ps1 | 51 +++++++++++++- FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 | 82 ++++++++++++++++++++++- 2 files changed, 129 insertions(+), 4 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 7250421..a4efdc0 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -759,6 +759,48 @@ function Update-WindowsVersionCombo { } } +# Function to refresh the Windows SKU ComboBox based on selected release +function Update-WindowsSkuCombo { + param( + [int]$selectedReleaseValue + ) + + $skuCombo = $script:cmbWindowsSKU + if (-not $skuCombo) { + WriteLog "Update-WindowsSkuCombo: SKU ComboBox not found." + return + } + + $previousSelectedSku = $null + if ($null -ne $skuCombo.SelectedItem) { + $previousSelectedSku = $skuCombo.SelectedItem + } + + WriteLog "Update-WindowsSkuCombo: Updating SKUs for Release Value '$selectedReleaseValue'." + $availableSkus = Get-AvailableSkusForRelease -SelectedReleaseValue $selectedReleaseValue + + $skuCombo.ItemsSource = $availableSkus + WriteLog "Update-WindowsSkuCombo: Set ItemsSource with $($availableSkus.Count) SKUs." + + # Attempt to re-select the previous SKU, or "Pro", or the first available + if ($null -ne $previousSelectedSku -and $availableSkus -contains $previousSelectedSku) { + $skuCombo.SelectedItem = $previousSelectedSku + WriteLog "Update-WindowsSkuCombo: Re-selected previous SKU '$previousSelectedSku'." + } + elseif ($availableSkus -contains "Pro") { + $skuCombo.SelectedItem = "Pro" + WriteLog "Update-WindowsSkuCombo: Selected default SKU 'Pro'." + } + elseif ($availableSkus.Count -gt 0) { + $skuCombo.SelectedIndex = 0 + WriteLog "Update-WindowsSkuCombo: Selected first available SKU '$($skuCombo.SelectedItem)'." + } + else { + $skuCombo.SelectedIndex = -1 # No SKUs available + WriteLog "Update-WindowsSkuCombo: No SKUs available for Release '$selectedReleaseValue'." + } +} + # Combined function to refresh both Release and Version combos $script:RefreshWindowsSettingsCombos = { param([string]$isoPath) @@ -774,6 +816,9 @@ $script:RefreshWindowsSettingsCombos = { # Update Version combo based on the selected release Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $isoPath + + # Update SKU combo based on the selected release + Update-WindowsSkuCombo -selectedReleaseValue $selectedReleaseValue } Add-Type -AssemblyName WindowsBase @@ -1681,6 +1726,8 @@ $window.Add_Loaded({ } # Only need to update the Version combo when Release changes Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $script:txtISOPath.Text + # Also update the SKU combo + Update-WindowsSkuCombo -selectedReleaseValue $selectedReleaseValue }) $script:btnBrowseISO.Add_Click({ $ofd = New-Object System.Windows.Forms.OpenFileDialog @@ -1696,8 +1743,8 @@ $window.Add_Loaded({ $script:cmbWindowsLang.ItemsSource = $script:windowsSettingsDefaults.AllowedLanguages $script:cmbWindowsLang.SelectedItem = $script:windowsSettingsDefaults.DefaultWindowsLang - $script:cmbWindowsSKU.ItemsSource = $script:windowsSettingsDefaults.SkuList - $script:cmbWindowsSKU.SelectedItem = $script:windowsSettingsDefaults.DefaultWindowsSKU + # $script:cmbWindowsSKU.ItemsSource is now populated by Update-WindowsSkuCombo called from RefreshWindowsSettingsCombos + $script:cmbWindowsSKU.SelectedItem = $script:windowsSettingsDefaults.DefaultWindowsSKU # Attempt to set default $script:cmbMediaType.ItemsSource = $script:windowsSettingsDefaults.AllowedMediaTypes $script:cmbMediaType.SelectedItem = $script:windowsSettingsDefaults.DefaultMediaType diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 index 5994bd6..afb8693 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 @@ -110,6 +110,61 @@ $script:windowsVersionMap = @{ 2025 = @("24H2") # Server 2025 } +# SKU Groups +$script:clientSKUs = @( + 'Home', + 'Home N', + 'Home Single Language', + 'Education', + 'Education N', + 'Pro', + 'Pro N', + 'Pro Education', + 'Pro Education N', + 'Pro for Workstations', + 'Pro N for Workstations', + 'Enterprise', + 'Enterprise N' +) + +$script:serverSKUs = @( + 'Standard', + 'Standard (Desktop Experience)', + 'Datacenter', + 'Datacenter (Desktop Experience)' +) + +$script:ltsc2016SKUs = @( + 'Enterprise 2016 LTSB', + 'Enterprise N 2016 LTSB' +) + +$script:ltscGenericSKUs = @( # For LTSC 2019, 2021, 2024 + 'Enterprise LTSC', + 'Enterprise N LTSC' +) + +$script:iotLtscSKUs = @( + 'IoT Enterprise LTSC', + 'IoT Enterprise N LTSC' + # Note: IoT SKUs are often specialized and might have different edition IDs. + # This list is a general representation. Actual ISOs might be needed for specific IoT LTSC editions. +) + +# Map Windows Release Values to their corresponding SKU lists +$script:windowsReleaseSkuMap = @{ + 10 = $script:clientSKUs # Windows 10 Client + 11 = $script:clientSKUs # Windows 11 Client + 2016 = $script:serverSKUs # Windows Server 2016 + 2019 = $script:serverSKUs # Windows Server 2019 + 2022 = $script:serverSKUs # Windows Server 2022 + 2025 = $script:serverSKUs # Windows Server 2025 + 1607 = $script:ltsc2016SKUs # Windows 10 LTSB 2016 + 1809 = $script:ltscGenericSKUs + $script:iotLtscSKUs # Windows 10 LTSC 2019 + 2021 = $script:ltscGenericSKUs + $script:iotLtscSKUs # Windows 10 LTSC 2021 + 2024 = $script:ltscGenericSKUs + $script:iotLtscSKUs # Windows 10 LTSC 2024 +} + # -------------------------------------------------------------------------- # SECTION: Logging Function (Moved from UI_Helpers) # -------------------------------------------------------------------------- @@ -204,7 +259,7 @@ function Get-WindowsSettingsDefaults { DefaultOptionalFeatures = "" DefaultProductKey = "" AllowedFeatures = $script:allowedFeatures # Return the list - SkuList = $script:skuList + # SkuList will now be populated dynamically based on Windows Release AllowedLanguages = $script:allowedLangs AllowedArchitectures = @('x86', 'x64', 'arm64') AllowedMediaTypes = @('Consumer', 'Business') @@ -279,6 +334,28 @@ function Get-AvailableWindowsVersions { return $result } +# Function to get available SKUs for a given Windows Release value +function Get-AvailableSkusForRelease { + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [int]$SelectedReleaseValue + ) + + WriteLog "Get-AvailableSkusForRelease: Getting SKUs for Release Value '$SelectedReleaseValue'." + + if ($script:windowsReleaseSkuMap.ContainsKey($SelectedReleaseValue)) { + $availableSkus = $script:windowsReleaseSkuMap[$SelectedReleaseValue] + WriteLog "Get-AvailableSkusForRelease: Found $($availableSkus.Count) SKUs for Release '$SelectedReleaseValue'." + return $availableSkus + } + else { + WriteLog "Get-AvailableSkusForRelease: Warning - Release Value '$SelectedReleaseValue' not found in SKU map. Returning default client SKUs." + # Fallback to a default list (e.g., client SKUs) or an empty list + return $script:clientSKUs + } +} + # Function to return general default settings for various UI elements (Moved from UI_Helpers) function Get-GeneralDefaults { [CmdletBinding()] @@ -3639,4 +3716,5 @@ Invoke-ProgressUpdate, Invoke-ParallelProcessing, Update-ListViewItemStatus, Update-OverallProgress, -Compress-DriverFolderToWim +Compress-DriverFolderToWim, +Get-AvailableSkusForRelease