Early HostnameChanger
-
While this isn’t directly related. The early name changer updates registry keys from what I understand.
The question in my mind is: Does any host name settings in the unattend.xml have an impact on the early host name change? I could envision that the EHNC would update the registry in the FOS environment, but the unattend.xml file contains something else which is executed on the first windows boot overwriting what is in the registry.
A bit off-point: I can say I don’t use FOG to change / set the host name. I use the unattend.xml file that is updated with a sed script during the post install phase of image deployment.
-
@george1421 nah, the unattend doesn’t touch the hostname.
-
@adukes40 OK in your unattend.xml file there isn’t a hostname section or if there is it contains a star ( * )?
-
@george1421 Without looking I do not know for certain. But now that you say it I think it is just an * which is why it names it TECHNOL-blahblah
-
just verified that for you. indeed:
<ComputerName>*</ComputerName>
-
@adukes40 I did a little Google searching on that, that line does set a generic name.
Seems it’s un-doing the Early Hostname Changer’s work perhaps?
-
@Wayne-Workman seems very plausible. I will update the image to remove the setting from the xml tomorrow.
Is that where you were going with the (*) George? the unattend overwriting the EHNC?
-
@adukes40 yes, that what ever was in the unattend.xml file is overwriting the registry. That sounds logical to how a sysprep’d image would work.
One might think that the following sed magic would change that computer name * to something FOG could manage. Where $unattendfile would be the full path and file name of the unattend file. One could slide that in a existing post install script or make a new one call fog.sethostname. Then you wouldn’t need the fog set host function at all.
sed -i -e "s#<ComputerName>\([^<][^<]*\)</ComputerName>#<ComputerName>$hostname</ComputerName>#gi" $unattendfile
-
@george1421 I’m not a sysprep person, is the unattend.xml file located in the same spot across different versions of Windows? Maybe this could be a feature in the fog inits? It could be a checkbox like the early hostname changer is. Just a general global setting that is on or off, and looks for this unattend file and makes changes if it’s found.
I imagine a whole lot is possible now in the realm of unattend.xml via BASH with those variables you exposed.
-
@Wayne-Workman For the sysprep unattend.xml file it is typically in 2 or 3 spots. The reference image creator can really put it anywhere the OOBE installer can find (on the local system). But it is typically in c:\windows\sysprep or c:\windows\panther.
Today I have unattend.xml set the system name with the below sed script, it also sets the timezone, AD OU, keyboard, region, and a few other things. All by patching the the unattend.xml file with sed and a few semi intelligent scripts.
For clarity the sed script for setting the host name will work today (yesterday) before the hostinfo.php script was included in the FOG base code. But now that it can be called there are more interesting things that can be done with the unattend.xml file.
You don’t need to use an unattend.xml file with sysprep so assuming there will always be one may fail. That is why I assume the fog client updates the registry to make the change (because not everyone uses sysprep and the unattend.xml file). Along the same lines when I get back to work I need to find out why a windows 10 system is not using a predefined unattend,xml file. There has to be a registry entry somewhere that tells it where the unattend.xml file is. There is one in the image, its just not using it for some reason. If I can find out why this win10 unattend.xml file isn’t being use I may be able to feed that info to the devs to help with the name changer function. At this point I don’t want to think too much about next week.
-
OK, so I ended up bypassing the HNC and EHNC all together. Being we need a reboot to occur before joining the domain, I created a powershell script to run on that first auto logon to take care of the name change. So the unattend names it with the * variable, then PS runs and pulls the current computer name, the asset from the bios, and serial from the bios and mashes them together and is working perfectly. Here is the script if it helps someone else gets started with their PS script:
#Rename the Workstation
$CurrerntComputerName = (Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name
$SerialNumber = (Get-WmiObject -Class Win32_BIOS | Select-Object SerialNumber).SerialNumber
$AssetTag = (Get-WmiObject -Class Win32_SystemEnclosure | Select-Object SMBiosAssetTag).SMBiosAssetTag$OSDComputerName = “$($AssetTag)-$($SerialNumber)”
Rename-Computer -ComputerName $CurrerntComputerName -NewName $OSDComputerName