Early HostnameChanger



  • So I just needs a little clarification on this. Does the HostnameChanger need to be enabled for the EarlyHostNameChanger name to take change. I didn’t think so because one is part of the FOG client, and the other happens while Linux is still handling everything. I ask because I made sure the Early HNC was enabled, and then disabled the HNC, and the machine name was technol blah blah. instead of what the fog gui shows. I just updated to the newest 79xx version (not at work, forgot what it is, but just upgraded about an hour ago)



  • 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


  • Moderator

    @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.


  • Moderator

    @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.


  • Moderator

    @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
    


  • @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?


  • Moderator

    @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?



  • just verified that for you. indeed:

    <ComputerName>*</ComputerName>



  • @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


  • Moderator

    @adukes40 OK in your unattend.xml file there isn’t a hostname section or if there is it contains a star ( * )?



  • @george1421 nah, the unattend doesn’t touch the hostname.


  • Moderator

    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.



  • @Wayne-Workman Win7 32bit, Enterprise, Machine is sysprep’d, FOG service disabled on master image, then re-enabled during the setupcomplete.cmd


  • Moderator

    @adukes40 There’s been a few questions raised lately about the early hostname change. Some changes have been made to it in the last weeks. I think it’s worth asking the @Senior-Developers about it.

    What version of Windows are you working with? Is it sys-prepped?



  • @Wayne-Workman correct, but it didn’t seem to be changing the name unless they were both enabled, and I do believe it is causing an unwanted reboot. I came back to a machine that was waiting for the local admin account to logon, insinuating that the 2 autologons occurred, which would mean HNC burnt one. While it was turned off, and Early was checked, it wasn’t naming it, but also wasn’t burning a reboot, only after i reenabled the client HNC version. I can check again tomorrow. Just now sure why it is being a issue now.


  • Moderator

    @adukes40 They are two entirely separate features, just as you thought. Although they use the same method. They just do registry edits in many different known places to change the hostname. One doesn’t need enabled for the other to work. However, I’d recommend leaving both turned on. It’ll save you a reboot when imaging.


Log in to reply
 

393
Online

38920
Users

10688
Topics

101407
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.