From 4b4f5eba8c98798e53ec30d2f8f7ac19a0fac1c8 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Fri, 13 Jun 2025 13:43:43 -0700 Subject: [PATCH] Refactors UI configuration and state management Moves UI configuration loading and retrieval logic into a new `FFUUI.Core.Config` module. Removes the `Set-UIValue` helper function from `BuildFFUVM_UI.ps1` and the `Get-UIConfig` function from `FFUUI.Core.psm1`. This centralizes UI-related configuration handling for improved modularity. --- FFUDevelopment/BuildFFUVM_UI.ps1 | 119 --------- .../FFUUI.Core/FFUUI.Core.Config.psm1 | 227 ++++++++++++++++++ FFUDevelopment/FFUUI.Core/FFUUI.Core.psd1 | 5 +- FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 | 111 --------- 4 files changed, 230 insertions(+), 232 deletions(-) create mode 100644 FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 8866f86..bd9905b 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -79,125 +79,6 @@ else { WriteLog "LongPathsEnabled is already set to 1." } -# ---------------------------------------------------------------------------- -# SECTION: LOAD UI -# ---------------------------------------------------------------------------- - -# Helper function to safely set UI properties from config and log the process -function Set-UIValue { - param( - [string]$ControlName, - [string]$PropertyName, - [object]$ConfigObject, - [string]$ConfigKey, - [scriptblock]$TransformValue = $null, # Optional scriptblock to transform the value from config - [psobject]$State # Pass the $State object - ) - - $control = $State.Controls[$ControlName] - if ($null -eq $control) { - WriteLog "LoadConfig Error: Control '$ControlName' not found in the state object." - return - } - - # Robust check for property existence. - $keyExists = $false - if ($ConfigObject -is [System.Management.Automation.PSCustomObject] -and $null -ne $ConfigObject.PSObject.Properties) { - # Use the Match() method, which returns a collection of matching properties. - # If the count is greater than 0, the key exists. - try { - if (($ConfigObject.PSObject.Properties.Match($ConfigKey)).Count -gt 0) { - $keyExists = $true - } - } - catch { - WriteLog "ERROR: Exception while trying to Match key '$ConfigKey' on ConfigObject.PSObject.Properties. Error: $($_.Exception.Message)" - # $keyExists remains false - } - } - - if (-not $keyExists) { - WriteLog "LoadConfig Info: Key '$ConfigKey' not found in configuration object. Skipping '$ControlName.$PropertyName'." - return - } - - $valueFromConfig = $ConfigObject.$ConfigKey - WriteLog "LoadConfig: Preparing to set '$ControlName.$PropertyName'. Config key: '$ConfigKey', Raw value: '$valueFromConfig'." - - $finalValue = $valueFromConfig - if ($null -ne $TransformValue) { - try { - $finalValue = Invoke-Command -ScriptBlock $TransformValue -ArgumentList $valueFromConfig - WriteLog "LoadConfig: Transformed value for '$ControlName.$PropertyName' (from key '$ConfigKey') is: '$finalValue'." - } - catch { - WriteLog "LoadConfig Error: Failed to transform value for '$ControlName.$PropertyName' from key '$ConfigKey'. Error: $($_.Exception.Message)" - return - } - } - - try { - # Handle ComboBox SelectedItem specifically - if ($control -is [System.Windows.Controls.ComboBox] -and $PropertyName -eq 'SelectedItem') { - $itemToSelect = $null - # Iterate through the Items collection of the ComboBox - foreach ($item in $control.Items) { - $itemValue = $null - if ($item -is [System.Windows.Controls.ComboBoxItem]) { - $itemValue = $item.Content - } - elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Value']) { - $itemValue = $item.Value - } - elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Display']) { - # Assuming 'Display' might be used if 'Value' isn't - $itemValue = $item.Display - } - else { - $itemValue = $item # For simple string items or direct object comparison - } - - # Compare, ensuring types are compatible or converting $finalValue if necessary - if (($null -ne $itemValue -and $itemValue.ToString() -eq $finalValue.ToString()) -or ($item -eq $finalValue)) { - $itemToSelect = $item - break - } - } - - if ($null -ne $itemToSelect) { - $control.SelectedItem = $itemToSelect - WriteLog "LoadConfig: Successfully set '$ControlName.SelectedItem' by finding matching item for value '$finalValue'." - } - elseif ($control.IsEditable -and ($finalValue -is [string] -or $finalValue -is [int] -or $finalValue -is [long])) { - $control.Text = $finalValue.ToString() - WriteLog "LoadConfig: Set '$ControlName.Text' to '$($finalValue.ToString())' as SelectedItem match failed (editable ComboBox)." - } - else { - $itemsString = "" - try { - # Safer way to get item strings - $itemStrings = @() - foreach ($cbItem in $control.Items) { - if ($null -ne $cbItem) { $itemStrings += $cbItem.ToString() } else { $itemStrings += "[NULL_ITEM]" } - } - $itemsString = $itemStrings -join "; " - } - catch { $itemsString = "Error retrieving item strings." } - WriteLog "LoadConfig Warning: Could not find or set item matching value '$finalValue' for '$ControlName.SelectedItem'. Current items: [$itemsString]" - } - } - else { - # For other properties or controls - $control.$PropertyName = $finalValue - WriteLog "LoadConfig: Successfully set '$ControlName.$PropertyName' to '$finalValue'." - } - } - catch { - WriteLog "LoadConfig Error: Failed to set '$ControlName.$PropertyName' to '$finalValue'. Error: $($_.Exception.Message)" - } -} - -#Remove old log file if found if (Test-Path -Path $script:uiState.LogFilePath) { Remove-item -Path $script:uiState.LogFilePath -Force } diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 new file mode 100644 index 0000000..2777807 --- /dev/null +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 @@ -0,0 +1,227 @@ +# FFU UI Core Configuration Module +# Contains functions for loading and saving UI configuration. + +function Get-UIConfig { + param( + [Parameter(Mandatory = $true)] + [psobject]$State + ) + # Create hash to store configuration + $config = [ordered]@{ + AllowExternalHardDiskMedia = $State.Controls.chkAllowExternalHardDiskMedia.IsChecked + AllowVHDXCaching = $State.Controls.chkAllowVHDXCaching.IsChecked + AppListPath = $State.Controls.txtAppListJsonPath.Text + AppsPath = $State.Controls.txtApplicationPath.Text + AppsScriptVariables = if ($State.Controls.chkDefineAppsScriptVariables.IsChecked) { + $vars = @{} + foreach ($item in $State.Data.appsScriptVariablesDataList) { + $vars[$item.Key] = $item.Value + } + if ($vars.Count -gt 0) { $vars } else { $null } + } + else { $null } + BuildUSBDrive = $State.Controls.chkBuildUSBDriveEnable.IsChecked + CleanupAppsISO = $State.Controls.chkCleanupAppsISO.IsChecked + CleanupCaptureISO = $State.Controls.chkCleanupCaptureISO.IsChecked + CleanupDeployISO = $State.Controls.chkCleanupDeployISO.IsChecked + CleanupDrivers = $State.Controls.chkCleanupDrivers.IsChecked + CompactOS = $State.Controls.chkCompactOS.IsChecked + CompressDownloadedDriversToWim = $State.Controls.chkCompressDriversToWIM.IsChecked + CopyAutopilot = $State.Controls.chkCopyAutopilot.IsChecked + CopyDrivers = $State.Controls.chkCopyDrivers.IsChecked + CopyOfficeConfigXML = $State.Controls.chkCopyOfficeConfigXML.IsChecked + CopyPEDrivers = $State.Controls.chkCopyPEDrivers.IsChecked + CopyPPKG = $State.Controls.chkCopyPPKG.IsChecked + CopyUnattend = $State.Controls.chkCopyUnattend.IsChecked + CreateCaptureMedia = $State.Controls.chkCreateCaptureMedia.IsChecked + CreateDeploymentMedia = $State.Controls.chkCreateDeploymentMedia.IsChecked + CustomFFUNameTemplate = $State.Controls.txtCustomFFUNameTemplate.Text + Disksize = [int64]$State.Controls.txtDiskSize.Text * 1GB + DownloadDrivers = $State.Controls.chkDownloadDrivers.IsChecked + DriversFolder = $State.Controls.txtDriversFolder.Text + DriversJsonPath = $State.Controls.txtDriversJsonPath.Text + FFUCaptureLocation = $State.Controls.txtFFUCaptureLocation.Text + FFUDevelopmentPath = $State.Controls.txtFFUDevPath.Text + FFUPrefix = $State.Controls.txtVMNamePrefix.Text + InstallApps = $State.Controls.chkInstallApps.IsChecked + InstallDrivers = $State.Controls.chkInstallDrivers.IsChecked + InstallOffice = $State.Controls.chkInstallOffice.IsChecked + InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked + ISOPath = $State.Controls.txtISOPath.Text + LogicalSectorSizeBytes = [int]$State.Controls.cmbLogicalSectorSize.SelectedItem.Content + Make = $State.Controls.cmbMake.SelectedItem + MediaType = $State.Controls.cmbMediaType.SelectedItem + Memory = [int64]$State.Controls.txtMemory.Text * 1GB + Model = if ($State.Controls.chkDownloadDrivers.IsChecked) { + $selectedModels = $State.Controls.lstDriverModels.Items | Where-Object { $_.IsSelected } + if ($selectedModels.Count -ge 1) { + $selectedModels[0].Model + } + else { + $null + } + } + else { + $null + } + OfficeConfigXMLFile = $State.Controls.txtOfficeConfigXMLFilePath.Text + OfficePath = $State.Controls.txtOfficePath.Text + Optimize = $State.Controls.chkOptimize.IsChecked + OptionalFeatures = $State.Controls.txtOptionalFeatures.Text + OrchestrationPath = "$($State.Controls.txtApplicationPath.Text)\Orchestration" + PEDriversFolder = $State.Controls.txtPEDriversFolder.Text + Processors = [int]$State.Controls.txtProcessors.Text + ProductKey = $State.Controls.txtProductKey.Text + PromptExternalHardDiskMedia = $State.Controls.chkPromptExternalHardDiskMedia.IsChecked + RemoveApps = $State.Controls.chkRemoveApps.IsChecked + RemoveFFU = $State.Controls.chkRemoveFFU.IsChecked + RemoveUpdates = $State.Controls.chkRemoveUpdates.IsChecked + ShareName = $State.Controls.txtShareName.Text + UpdateADK = $State.Controls.chkUpdateADK.IsChecked + UpdateEdge = $State.Controls.chkUpdateEdge.IsChecked + UpdateLatestCU = $State.Controls.chkUpdateLatestCU.IsChecked + UpdateLatestDefender = $State.Controls.chkUpdateLatestDefender.IsChecked + UpdateLatestMicrocode = $State.Controls.chkUpdateLatestMicrocode.IsChecked + UpdateLatestMSRT = $State.Controls.chkUpdateLatestMSRT.IsChecked + UpdateLatestNet = $State.Controls.chkUpdateLatestNet.IsChecked + UpdateOneDrive = $State.Controls.chkUpdateOneDrive.IsChecked + UpdatePreviewCU = $State.Controls.chkUpdatePreviewCU.IsChecked + UserAppListPath = "$($State.Controls.txtApplicationPath.Text)\UserAppList.json" + USBDriveList = @{} + Username = $State.Controls.txtUsername.Text + VMHostIPAddress = $State.Controls.txtVMHostIPAddress.Text + VMLocation = $State.Controls.txtVMLocation.Text + VMSwitchName = if ($State.Controls.cmbVMSwitchName.SelectedItem -eq 'Other') { + $State.Controls.txtCustomVMSwitchName.Text + } + else { + $State.Controls.cmbVMSwitchName.SelectedItem + } + WindowsArch = $State.Controls.cmbWindowsArch.SelectedItem + WindowsLang = $State.Controls.cmbWindowsLang.SelectedItem + WindowsRelease = [int]$State.Controls.cmbWindowsRelease.SelectedItem.Value + WindowsSKU = $State.Controls.cmbWindowsSKU.SelectedItem + WindowsVersion = $State.Controls.cmbWindowsVersion.SelectedItem + } + + $State.Controls.lstUSBDrives.Items | Where-Object { $_.IsSelected } | ForEach-Object { + $config.USBDriveList[$_.Model] = $_.SerialNumber + } + + return $config +} + +function Set-UIValue { + param( + [string]$ControlName, + [string]$PropertyName, + [object]$ConfigObject, + [string]$ConfigKey, + [scriptblock]$TransformValue = $null, # Optional scriptblock to transform the value from config + [psobject]$State # Pass the $State object + ) + + $control = $State.Controls[$ControlName] + if ($null -eq $control) { + WriteLog "LoadConfig Error: Control '$ControlName' not found in the state object." + return + } + + # Robust check for property existence. + $keyExists = $false + if ($ConfigObject -is [System.Management.Automation.PSCustomObject] -and $null -ne $ConfigObject.PSObject.Properties) { + # Use the Match() method, which returns a collection of matching properties. + # If the count is greater than 0, the key exists. + try { + if (($ConfigObject.PSObject.Properties.Match($ConfigKey)).Count -gt 0) { + $keyExists = $true + } + } + catch { + WriteLog "ERROR: Exception while trying to Match key '$ConfigKey' on ConfigObject.PSObject.Properties. Error: $($_.Exception.Message)" + # $keyExists remains false + } + } + + if (-not $keyExists) { + WriteLog "LoadConfig Info: Key '$ConfigKey' not found in configuration object. Skipping '$ControlName.$PropertyName'." + return + } + + $valueFromConfig = $ConfigObject.$ConfigKey + WriteLog "LoadConfig: Preparing to set '$ControlName.$PropertyName'. Config key: '$ConfigKey', Raw value: '$valueFromConfig'." + + $finalValue = $valueFromConfig + if ($null -ne $TransformValue) { + try { + $finalValue = Invoke-Command -ScriptBlock $TransformValue -ArgumentList $valueFromConfig + WriteLog "LoadConfig: Transformed value for '$ControlName.$PropertyName' (from key '$ConfigKey') is: '$finalValue'." + } + catch { + WriteLog "LoadConfig Error: Failed to transform value for '$ControlName.$PropertyName' from key '$ConfigKey'. Error: $($_.Exception.Message)" + return + } + } + + try { + # Handle ComboBox SelectedItem specifically + if ($control -is [System.Windows.Controls.ComboBox] -and $PropertyName -eq 'SelectedItem') { + $itemToSelect = $null + # Iterate through the Items collection of the ComboBox + foreach ($item in $control.Items) { + $itemValue = $null + if ($item -is [System.Windows.Controls.ComboBoxItem]) { + $itemValue = $item.Content + } + elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Value']) { + $itemValue = $item.Value + } + elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Display']) { + # Assuming 'Display' might be used if 'Value' isn't + $itemValue = $item.Display + } + else { + $itemValue = $item # For simple string items or direct object comparison + } + + # Compare, ensuring types are compatible or converting $finalValue if necessary + if (($null -ne $itemValue -and $itemValue.ToString() -eq $finalValue.ToString()) -or ($item -eq $finalValue)) { + $itemToSelect = $item + break + } + } + + if ($null -ne $itemToSelect) { + $control.SelectedItem = $itemToSelect + WriteLog "LoadConfig: Successfully set '$ControlName.SelectedItem' by finding matching item for value '$finalValue'." + } + elseif ($control.IsEditable -and ($finalValue -is [string] -or $finalValue -is [int] -or $finalValue -is [long])) { + $control.Text = $finalValue.ToString() + WriteLog "LoadConfig: Set '$ControlName.Text' to '$($finalValue.ToString())' as SelectedItem match failed (editable ComboBox)." + } + else { + $itemsString = "" + try { + # Safer way to get item strings + $itemStrings = @() + foreach ($cbItem in $control.Items) { + if ($null -ne $cbItem) { $itemStrings += $cbItem.ToString() } else { $itemStrings += "[NULL_ITEM]" } + } + $itemsString = $itemStrings -join "; " + } + catch { $itemsString = "Error retrieving item strings." } + WriteLog "LoadConfig Warning: Could not find or set item matching value '$finalValue' for '$ControlName.SelectedItem'. Current items: [$itemsString]" + } + } + else { + # For other properties or controls + $control.$PropertyName = $finalValue + WriteLog "LoadConfig: Successfully set '$ControlName.$PropertyName' to '$finalValue'." + } + } + catch { + WriteLog "LoadConfig Error: Failed to set '$ControlName.$PropertyName' to '$finalValue'. Error: $($_.Exception.Message)" + } +} + +Export-ModuleMember -Function Get-UIConfig, Set-UIValue \ No newline at end of file diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psd1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psd1 index 86f1151..5f286f4 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psd1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psd1 @@ -66,13 +66,14 @@ RequiredModules = @('..\FFU.Common\FFU.Common.psd1') # FormatsToProcess = @() # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @('FFUUI.Core.Shared.psm1', - 'FFUUI.Core.Applications.psm1', +NestedModules = @('FFUUI.Core.Applications.psm1', + 'FFUUI.Core.Config.psm1', 'FFUUI.Core.Drivers.psm1', 'FFUUI.Core.Drivers.Dell.psm1', 'FFUUI.Core.Drivers.HP.psm1', 'FFUUI.Core.Drivers.Lenovo.psm1', 'FFUUI.Core.Drivers.Microsoft.psm1', + 'FFUUI.Core.Shared.psm1', 'FFUUI.Core.WindowsSettings.psm1', 'FFUUI.Core.Winget.psm1') diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 index 2344940..888b62a 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.psm1 @@ -190,118 +190,7 @@ function Get-USBDrives { } } -# -------------------------------------------------------------------------- -# SECTION: UI Configuration -# -------------------------------------------------------------------------- -function Get-UIConfig { - param( - [Parameter(Mandatory = $true)] - [psobject]$State - ) - # Create hash to store configuration - $config = [ordered]@{ - AllowExternalHardDiskMedia = $State.Controls.chkAllowExternalHardDiskMedia.IsChecked - AllowVHDXCaching = $State.Controls.chkAllowVHDXCaching.IsChecked - AppListPath = $State.Controls.txtAppListJsonPath.Text - AppsPath = $State.Controls.txtApplicationPath.Text - AppsScriptVariables = if ($State.Controls.chkDefineAppsScriptVariables.IsChecked) { - $vars = @{} - foreach ($item in $State.Data.appsScriptVariablesDataList) { - $vars[$item.Key] = $item.Value - } - if ($vars.Count -gt 0) { $vars } else { $null } - } - else { $null } - BuildUSBDrive = $State.Controls.chkBuildUSBDriveEnable.IsChecked - CleanupAppsISO = $State.Controls.chkCleanupAppsISO.IsChecked - CleanupCaptureISO = $State.Controls.chkCleanupCaptureISO.IsChecked - CleanupDeployISO = $State.Controls.chkCleanupDeployISO.IsChecked - CleanupDrivers = $State.Controls.chkCleanupDrivers.IsChecked - CompactOS = $State.Controls.chkCompactOS.IsChecked - CompressDownloadedDriversToWim = $State.Controls.chkCompressDriversToWIM.IsChecked - CopyAutopilot = $State.Controls.chkCopyAutopilot.IsChecked - CopyDrivers = $State.Controls.chkCopyDrivers.IsChecked - CopyOfficeConfigXML = $State.Controls.chkCopyOfficeConfigXML.IsChecked - CopyPEDrivers = $State.Controls.chkCopyPEDrivers.IsChecked - CopyPPKG = $State.Controls.chkCopyPPKG.IsChecked - CopyUnattend = $State.Controls.chkCopyUnattend.IsChecked - CreateCaptureMedia = $State.Controls.chkCreateCaptureMedia.IsChecked - CreateDeploymentMedia = $State.Controls.chkCreateDeploymentMedia.IsChecked - CustomFFUNameTemplate = $State.Controls.txtCustomFFUNameTemplate.Text - Disksize = [int64]$State.Controls.txtDiskSize.Text * 1GB - DownloadDrivers = $State.Controls.chkDownloadDrivers.IsChecked - DriversFolder = $State.Controls.txtDriversFolder.Text - DriversJsonPath = $State.Controls.txtDriversJsonPath.Text - FFUCaptureLocation = $State.Controls.txtFFUCaptureLocation.Text - FFUDevelopmentPath = $State.Controls.txtFFUDevPath.Text - FFUPrefix = $State.Controls.txtVMNamePrefix.Text - InstallApps = $State.Controls.chkInstallApps.IsChecked - InstallDrivers = $State.Controls.chkInstallDrivers.IsChecked - InstallOffice = $State.Controls.chkInstallOffice.IsChecked - InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked - ISOPath = $State.Controls.txtISOPath.Text - LogicalSectorSizeBytes = [int]$State.Controls.cmbLogicalSectorSize.SelectedItem.Content - Make = $State.Controls.cmbMake.SelectedItem - MediaType = $State.Controls.cmbMediaType.SelectedItem - Memory = [int64]$State.Controls.txtMemory.Text * 1GB - Model = if ($State.Controls.chkDownloadDrivers.IsChecked) { - $selectedModels = $State.Controls.lstDriverModels.Items | Where-Object { $_.IsSelected } - if ($selectedModels.Count -ge 1) { - $selectedModels[0].Model - } - else { - $null - } - } - else { - $null - } - OfficeConfigXMLFile = $State.Controls.txtOfficeConfigXMLFilePath.Text - OfficePath = $State.Controls.txtOfficePath.Text - Optimize = $State.Controls.chkOptimize.IsChecked - OptionalFeatures = $State.Controls.txtOptionalFeatures.Text - OrchestrationPath = "$($State.Controls.txtApplicationPath.Text)\Orchestration" - PEDriversFolder = $State.Controls.txtPEDriversFolder.Text - Processors = [int]$State.Controls.txtProcessors.Text - ProductKey = $State.Controls.txtProductKey.Text - PromptExternalHardDiskMedia = $State.Controls.chkPromptExternalHardDiskMedia.IsChecked - RemoveApps = $State.Controls.chkRemoveApps.IsChecked - RemoveFFU = $State.Controls.chkRemoveFFU.IsChecked - RemoveUpdates = $State.Controls.chkRemoveUpdates.IsChecked - ShareName = $State.Controls.txtShareName.Text - UpdateADK = $State.Controls.chkUpdateADK.IsChecked - UpdateEdge = $State.Controls.chkUpdateEdge.IsChecked - UpdateLatestCU = $State.Controls.chkUpdateLatestCU.IsChecked - UpdateLatestDefender = $State.Controls.chkUpdateLatestDefender.IsChecked - UpdateLatestMicrocode = $State.Controls.chkUpdateLatestMicrocode.IsChecked - UpdateLatestMSRT = $State.Controls.chkUpdateLatestMSRT.IsChecked - UpdateLatestNet = $State.Controls.chkUpdateLatestNet.IsChecked - UpdateOneDrive = $State.Controls.chkUpdateOneDrive.IsChecked - UpdatePreviewCU = $State.Controls.chkUpdatePreviewCU.IsChecked - UserAppListPath = "$($State.Controls.txtApplicationPath.Text)\UserAppList.json" - USBDriveList = @{} - Username = $State.Controls.txtUsername.Text - VMHostIPAddress = $State.Controls.txtVMHostIPAddress.Text - VMLocation = $State.Controls.txtVMLocation.Text - VMSwitchName = if ($State.Controls.cmbVMSwitchName.SelectedItem -eq 'Other') { - $State.Controls.txtCustomVMSwitchName.Text - } - else { - $State.Controls.cmbVMSwitchName.SelectedItem - } - WindowsArch = $State.Controls.cmbWindowsArch.SelectedItem - WindowsLang = $State.Controls.cmbWindowsLang.SelectedItem - WindowsRelease = [int]$State.Controls.cmbWindowsRelease.SelectedItem.Value - WindowsSKU = $State.Controls.cmbWindowsSKU.SelectedItem - WindowsVersion = $State.Controls.cmbWindowsVersion.SelectedItem - } - $State.Controls.lstUSBDrives.Items | Where-Object { $_.IsSelected } | ForEach-Object { - $config.USBDriveList[$_.Model] = $_.SerialNumber - } - - return $config -} # -------------------------------------------------------------------------- # SECTION: UI Initialization Functions