Fix: Clarify computer name is set on reboot

Updates the logging messages to more accurately reflect that the computer name change takes effect after a restart. The `Set-Computername` command stages the change, so the log now indicates the name "will be set" instead of "was set".
This commit is contained in:
rbalsleyMSFT
2025-08-06 17:01:04 -07:00
parent 5bef901295
commit 357261ec73
@@ -381,8 +381,8 @@ if ($Unattend -and $UnattendPrefix) {
$computername = $computername.substring(0, 15) $computername = $computername.substring(0, 15)
} }
$computername = Set-Computername($computername) $computername = Set-Computername($computername)
Writelog "Computer name set to $computername" Writelog "Computer name will be set to $computername"
Write-Host "Computer name set to $computername" Write-Host "Computer name will be set to $computername"
} }
elseif ($Unattend -and $UnattendComputerName) { elseif ($Unattend -and $UnattendComputerName) {
Writelog 'Unattend file found with SerialComputerNames.csv. Getting name for current computer.' Writelog 'Unattend file found with SerialComputerNames.csv. Getting name for current computer.'
@@ -394,16 +394,16 @@ elseif ($Unattend -and $UnattendComputerName) {
If ($SCName) { If ($SCName) {
[string]$computername = $SCName.ComputerName [string]$computername = $SCName.ComputerName
$computername = Set-Computername($computername) $computername = Set-Computername($computername)
Writelog "Computer name set to $computername" Writelog "Computer name will be set to $computername"
Write-Host "Computer name set to $computername" Write-Host "Computer name will be set to $computername"
} }
else { else {
Writelog 'No matching serial number found in SerialComputerNames.csv. Setting random computer name to complete setup.' Writelog 'No matching serial number found in SerialComputerNames.csv. Setting random computer name to complete setup.'
Write-Host 'No matching serial number found in SerialComputerNames.csv. Setting random computer name to complete setup.' Write-Host 'No matching serial number found in SerialComputerNames.csv. Setting random computer name to complete setup.'
[string]$computername = ("FFU-" + ( -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 11 | ForEach-Object { [char]$_ }))) [string]$computername = ("FFU-" + ( -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 11 | ForEach-Object { [char]$_ })))
$computername = Set-Computername($computername) $computername = Set-Computername($computername)
Writelog "Computer name set to $computername" Writelog "Computer name will be set to $computername"
Write-Host "Computer name set to $computername" Write-Host "Computer name will be set to $computername"
} }
} }
elseif ($Unattend) { elseif ($Unattend) {
@@ -411,8 +411,8 @@ elseif ($Unattend) {
Write-Host 'Unattend file found but no prefixes.txt. Please enter a device name.' Write-Host 'Unattend file found but no prefixes.txt. Please enter a device name.'
[string]$computername = Read-Host 'Enter device name' [string]$computername = Read-Host 'Enter device name'
Set-Computername($computername) Set-Computername($computername)
Writelog "Computer name set to $computername" Writelog "Computer name will be set to $computername"
Write-Host "Computer name set to $computername" Write-Host "Computer name will be set to $computername"
} }
else { else {
WriteLog 'No unattend folder found. Device name will be set via PPKG, AP JSON, or default OS name.' WriteLog 'No unattend folder found. Device name will be set via PPKG, AP JSON, or default OS name.'