6 Replies Latest reply on Oct 19, 2018 8:48 AM by jwood8

    Naming workstations during provisioning

    jwood8 Apprentice

      Hi all,


      How are people handling the naming of workstations during provisioning?


      On Win 7 we used to run some PowerShell and it worked fine. On Win 10 it seems intermittent at best. The code we use is:


      $servicetag = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber

      Rename-Computer -NewName $servicetag -Force


      The machines are Dell so the service tag is built in.


      We have this running as a provisioning step after imaging but before joining the domain.


      If you run this script as an admin after build, it works fine.


      Anyone got any better methods please?

        • 1. Re: Naming workstations during provisioning
          phoffmann SupportEmployee

          There's a couple of existing threads on this topic, have you checked those out for options (it'd help checking the OS Deployment and Provisioning  section ) - for example:


          I'm assuming that this is for NEW devices, rather than "updated from Win7 to Win10" devices? As that'd be covered here -- How to maintain Device Name after Re-Imaging .


          That'd be a good starting point.


          Talking of "posting in the right section" - going to move this thread over into the Provisioning section, as it should really belong into there.


          As an aside (not SUPER relevant in this case, but a good habit to get into) - always list what version you're using (i.e. "9.5 SP2" or "2017.3 + SU3" type of thing). That helps with context .


          As a general note, be mindful that prodding WMI during Provisioning is often a great recipe to find out that "it's not quite there yet" -- so I'd try to not rely too much on it during that time. You (well - we) run into "broken WMI" reasonably often enough to not trust it at the best of times, so I'd personally prefer using something like a device name prompter / automated device-naming convention (with an incrementing device number, for instance), rather than relying on (a) WMI in the first place, and (b) WMI not being broken.


          It tends to break at the most annoying of times (and is really hard to (dis-)prove beyond "data not being there").


          Hope that helps.

          • 2. Re: Naming workstations during provisioning
            jwood8 Apprentice

            Thanks for the reply!


            We can't use the device naming templates though because they don't pick up the service tag, they're only for using variables and sequential numbers unless I'm understanding it wrong?


            These are new devices yes, being imaged using a provisioning template booted from a USB stick. We deploy an image and then finish off with provisioning tasks. These are brand new machines out of boxes so they're not picking up existing ldhostname - I think if the machine exists already then it works OK but I could be wrong.


            I've seen some rumours about using the %servicetag% variable in the unattend script, does anyone do this and does it work?


            Version is (2018) and yes, I take your point about WMI too! It's just frustrating that it worked on Win 7 but not 10, especially annoying as the answer it shows on the right under 'More like this' is the article that *I* wrote about doing it on Win 7...!

            • 3. Re: Naming workstations during provisioning
              phoffmann SupportEmployee

              Gotcha - disconnected / USB-templates are a bit of extra-special, no doubt there.


              So - in the case that this is "off network", I'd argue, "just script your own" naming convention in a simple PS-script & then grab it out of an output file & inject it into your unattend?


              You could do something like "MAC-address" based naming (to ensure uniqueness (and then worry about renaming the devices once you've got a full on Windows 10 environment, perhaps)?


              I'm primarily trying to think of things that "don't use WMI" but "will be consistent & unique" ... can't think much beyond MAC-s at this point. Would that do (as a "temporary" name 'til you've got those suckers loaded up with Win-10 and up on the network perhaps?


              <My thought / concern being that you MIGHT have to go through WMI to get the MAC-address ... though I suppose you could "just" run something like "ipconfig /all" and parse the output for a physical address field in a PS-script perhaps?>


              Would that help?


              You could "generate a random number" sort of thing and go "device-12345678" but there's no guarantee of uniqueness here (let alone consistency) ... and I tend to find that "guaranteed uniqueness" is a very worthwhile thing to pursue during the vulnerable time of Provisioning a system first time?

              • 4. Re: Naming workstations during provisioning
                jwood8 Apprentice

                We're already getting unique names so that's not a problem (and just to be clear, it's still a network build just booting from USB rather than PXE so it's online) - so for example the machine I just built has been named WINDOWS-8J74HR7 instead of the correct service tag, even though the PowerShell script I mentioned has run during Provisioning and is showing success. We only need them to be named after the service tag, nothing else will work for our method. At present, the tech is having to build and then manually log in and run the self-same PowerShell script to rename the station which just seems like something I should be able to automate. Meh!

                • 5. Re: Naming workstations during provisioning
                  phoffmann SupportEmployee

                  So - what about "having a temporary name" during the intial build, and then (re-)running the PS-script to snatch the "correct name" once you're in a full Win-10 environment (which MIGHT work better, perhaps?).


                  You can include that "snatch & rename" just before a reboot & as long as it's happening before you join the domain proper (usually a last action anyway), that may be enough? A bit odd, perhaps, but may work around the nonsense you're seeing?


                  Or at least you could shoot up a message of some sort if your "name pattern" isn't what it's suppoed to be (RegEx check, assuming it's reasonably straight forward / consistent) ?

                  • 6. Re: Naming workstations during provisioning
                    jwood8 Apprentice

                    Yeah, I'm fine with it running that at any point but that's how it is now - template does the WinPE stuff, reboots, installs provisioning agent, activates Windows, then renames the station, joins the domain, then reboots and installs the full agent before completing. All the steps show success, but it doesn't do the rename. I will try messing with the order, just wondered if other people were using another method that was more reliable. Cheers!