mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Refactor Windows SKU handling to derive values internally and update mappings for LTSB/LTSC releases
- Updated Update-WindowsSkuCombo function to derive selected release value and display name from the ComboBox, removing the need for parameters. - Enhanced logging to include display names for better traceability. - Corrected SKU values for Windows 10 LTSB 2016 and LTSC 2019 in the release mappings. - Adjusted Get-AvailableSkusForRelease function to handle specific cases for LTSB 2016 and LTSC 2019, ensuring accurate SKU retrieval.
This commit is contained in:
@@ -761,9 +761,8 @@ function Update-WindowsVersionCombo {
|
||||
|
||||
# Function to refresh the Windows SKU ComboBox based on selected release
|
||||
function Update-WindowsSkuCombo {
|
||||
param(
|
||||
[int]$selectedReleaseValue
|
||||
)
|
||||
# This function no longer takes parameters.
|
||||
# It derives the selected release value and display name from the cmbWindowsRelease ComboBox.
|
||||
|
||||
$skuCombo = $script:cmbWindowsSKU
|
||||
if (-not $skuCombo) {
|
||||
@@ -771,13 +770,26 @@ function Update-WindowsSkuCombo {
|
||||
return
|
||||
}
|
||||
|
||||
$releaseCombo = $script:cmbWindowsRelease
|
||||
if (-not $releaseCombo -or $null -eq $releaseCombo.SelectedItem) {
|
||||
WriteLog "Update-WindowsSkuCombo: Windows Release ComboBox not found or no item selected. Cannot update SKUs."
|
||||
$skuCombo.ItemsSource = @() # Clear SKUs
|
||||
$skuCombo.SelectedIndex = -1
|
||||
return
|
||||
}
|
||||
|
||||
$selectedReleaseItem = $releaseCombo.SelectedItem
|
||||
$selectedReleaseValue = $selectedReleaseItem.Value
|
||||
$selectedReleaseDisplayName = $selectedReleaseItem.Display
|
||||
|
||||
$previousSelectedSku = $null
|
||||
if ($null -ne $skuCombo.SelectedItem) {
|
||||
$previousSelectedSku = $skuCombo.SelectedItem
|
||||
}
|
||||
|
||||
WriteLog "Update-WindowsSkuCombo: Updating SKUs for Release Value '$selectedReleaseValue'."
|
||||
$availableSkus = Get-AvailableSkusForRelease -SelectedReleaseValue $selectedReleaseValue
|
||||
WriteLog "Update-WindowsSkuCombo: Updating SKUs for Release Value '$selectedReleaseValue' (Display: '$selectedReleaseDisplayName')."
|
||||
# Call Get-AvailableSkusForRelease with both Value and DisplayName
|
||||
$availableSkus = Get-AvailableSkusForRelease -SelectedReleaseValue $selectedReleaseValue -SelectedReleaseDisplayName $selectedReleaseDisplayName
|
||||
|
||||
$skuCombo.ItemsSource = $availableSkus
|
||||
WriteLog "Update-WindowsSkuCombo: Set ItemsSource with $($availableSkus.Count) SKUs."
|
||||
@@ -797,7 +809,7 @@ function Update-WindowsSkuCombo {
|
||||
}
|
||||
else {
|
||||
$skuCombo.SelectedIndex = -1 # No SKUs available
|
||||
WriteLog "Update-WindowsSkuCombo: No SKUs available for Release '$selectedReleaseValue'."
|
||||
WriteLog "Update-WindowsSkuCombo: No SKUs available for Release '$selectedReleaseValue' (Display: '$selectedReleaseDisplayName')."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,8 +829,8 @@ $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
|
||||
# Update SKU combo based on the selected release (now derives values internally)
|
||||
Update-WindowsSkuCombo
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName WindowsBase
|
||||
@@ -1726,8 +1738,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
|
||||
# Also update the SKU combo (now derives values internally)
|
||||
Update-WindowsSkuCombo
|
||||
})
|
||||
$script:btnBrowseISO.Add_Click({
|
||||
$ofd = New-Object System.Windows.Forms.OpenFileDialog
|
||||
|
||||
@@ -86,8 +86,8 @@ $script:allWindowsReleases = @(
|
||||
[PSCustomObject]@{ Display = "Windows Server 2019"; Value = 2019 },
|
||||
[PSCustomObject]@{ Display = "Windows Server 2022"; Value = 2022 },
|
||||
[PSCustomObject]@{ Display = "Windows Server 2025"; Value = 2025 },
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSB 2016"; Value = 1607 },
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSC 2019"; Value = 1809 },
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSB 2016"; Value = 2016 }, # Changed Value from 1607
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSC 2019"; Value = 2019 }, # Changed Value from 1809
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSC 2021"; Value = 2021 },
|
||||
[PSCustomObject]@{ Display = "Windows 10 LTSC 2024"; Value = 2024 }
|
||||
)
|
||||
@@ -100,10 +100,10 @@ $script:mctWindowsReleases = @(
|
||||
$script:windowsVersionMap = @{
|
||||
10 = @("22H2")
|
||||
11 = @("22H2", "23H2", "24H2")
|
||||
1607 = @("1607") # Windows 10 LTSB 2016
|
||||
1809 = @("1809") # Windows 10 LTSC 2019
|
||||
2016 = @("1607") # Server 2016
|
||||
2019 = @("1809") # Server 2019
|
||||
2016 = @("1607") # Windows 10 LTSB 2016 & Server 2016
|
||||
2019 = @("1809") # Windows 10 LTSC 2019 & Server 2019
|
||||
# Note: Server 2016 and LTSB 2016 now share the key 2016, mapping to version "1607"
|
||||
# Note: Server 2019 and LTSC 2019 now share the key 2019, mapping to version "1809"
|
||||
2021 = @("21H2") # LTSC 2021
|
||||
2022 = @("21H2") # Server 2022
|
||||
2024 = @("24H2") # LTSC 2024
|
||||
@@ -155,14 +155,13 @@ $script:iotLtscSKUs = @(
|
||||
$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
|
||||
2016 = $script:serverSKUs # Windows Server 2016 (LTSB 2016 handled by Get-AvailableSkusForRelease)
|
||||
2019 = $script:serverSKUs # Windows Server 2019 (LTSC 2019 handled by Get-AvailableSkusForRelease)
|
||||
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
|
||||
# Note: LTSC 2016 and LTSC 2019 SKUs are now conditionally returned by Get-AvailableSkusForRelease
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@@ -334,19 +333,35 @@ function Get-AvailableWindowsVersions {
|
||||
return $result
|
||||
}
|
||||
|
||||
# Function to get available SKUs for a given Windows Release value
|
||||
# Function to get available SKUs for a given Windows Release value and display name
|
||||
function Get-AvailableSkusForRelease {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[int]$SelectedReleaseValue
|
||||
[int]$SelectedReleaseValue,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$SelectedReleaseDisplayName
|
||||
)
|
||||
|
||||
WriteLog "Get-AvailableSkusForRelease: Getting SKUs for Release Value '$SelectedReleaseValue'."
|
||||
WriteLog "Get-AvailableSkusForRelease: Getting SKUs for Release Value '$SelectedReleaseValue', Display Name '$SelectedReleaseDisplayName'."
|
||||
|
||||
if ($script:windowsReleaseSkuMap.ContainsKey($SelectedReleaseValue)) {
|
||||
# Handle LTSC 2016 specifically
|
||||
if ($SelectedReleaseValue -eq 2016 -and $SelectedReleaseDisplayName -like '*LTSB*') {
|
||||
WriteLog "Get-AvailableSkusForRelease: Matched LTSB 2016. Returning LTSC 2016 SKUs."
|
||||
return $script:ltsc2016SKUs
|
||||
}
|
||||
# Handle LTSC 2019 specifically
|
||||
# Ensure "Server" is not in the display name to avoid matching "Windows Server 2019"
|
||||
elseif ($SelectedReleaseValue -eq 2019 -and $SelectedReleaseDisplayName -like '*LTSC*' -and $SelectedReleaseDisplayName -notlike '*Server*') {
|
||||
WriteLog "Get-AvailableSkusForRelease: Matched LTSC 2019. Returning generic LTSC SKUs (including IoT)."
|
||||
# Assuming LTSC 2019 uses the generic LTSC SKUs + IoT LTSC SKUs
|
||||
return ($script:ltscGenericSKUs + $script:iotLtscSKUs | Select-Object -Unique)
|
||||
}
|
||||
# For all other cases, use the main SKU map
|
||||
elseif ($script:windowsReleaseSkuMap.ContainsKey($SelectedReleaseValue)) {
|
||||
$availableSkus = $script:windowsReleaseSkuMap[$SelectedReleaseValue]
|
||||
WriteLog "Get-AvailableSkusForRelease: Found $($availableSkus.Count) SKUs for Release '$SelectedReleaseValue'."
|
||||
WriteLog "Get-AvailableSkusForRelease: Found $($availableSkus.Count) SKUs for Release '$SelectedReleaseValue' using standard map."
|
||||
return $availableSkus
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user