Deduplicate device name section header output

Moves the 'Device Name Selection' section header out of the conditional blocks to a common location. This refactoring avoids code repetition and improves maintainability.
This commit is contained in:
rbalsleyMSFT
2025-08-06 16:42:54 -07:00
parent 59e247c012
commit 5bef901295
@@ -337,8 +337,8 @@ If (Test-Path -Path $UnattendComputerNamePath) {
}
#Ask for device name if unattend exists
Write-SectionHeader 'Device Name Selection'
if ($Unattend -and $UnattendPrefix) {
Write-SectionHeader 'Device Name Selection'
Writelog 'Unattend file found with prefixes.txt. Getting prefixes.'
$UnattendPrefixes = @(Get-content $UnattendPrefixFile)
$UnattendPrefixCount = $UnattendPrefixes.Count
@@ -385,7 +385,6 @@ if ($Unattend -and $UnattendPrefix) {
Write-Host "Computer name set to $computername"
}
elseif ($Unattend -and $UnattendComputerName) {
Write-SectionHeader 'Device Name Selection'
Writelog 'Unattend file found with SerialComputerNames.csv. Getting name for current computer.'
$SerialComputerNames = Import-Csv -Path $UnattendComputerNameFile.FullName -Delimiter ","