3 Replies Latest reply on Jun 2, 2017 10:04 AM by dgonzalez

    Using PARTIAL serial number as computer name in provisioning

    redpantsdvm Rookie

      I've read this post:

       

      Using serial number as computer name in provisioning

       

      Does anyone know a way to include only part of the serial number, like the last 4 or 5 numbers?

       

      We are imaging using provisioning and creating a naming template and want to include serial but not all or the name will be quite long.

       

      Thanks.

        • 1. Re: Using PARTIAL serial number as computer name in provisioning
          Peteski Apprentice

          I can only think of a way to do it post-OS deployment in the system configuration section. Just inject a simple powershell script, execute it and add a reboot action. Join domain action to follow if that's required.

           

          ***PS script***

          $comp = gwmi win32_computersystem

          $serial = (gwmi win32_operatingsystem).serialnumber

          $newname = "newpcname"+$($serial.Substring($serial.Length-5))

          $comp.rename($newname)

          1 of 1 people found this helpful
          • 2. Re: Using PARTIAL serial number as computer name in provisioning
            bcstring SupportEmployee

            Redpantsdvm,

             

               This is possible using the Device Name Template feature of Provisioning with your Device Name Prompter action. About Device Naming Templates

             

            Bryce.

            • 3. Re: Using PARTIAL serial number as computer name in provisioning
              Apprentice

              I came up with the following simple PS script, instead of using Inject unattend file.

               

              $path = 'c:\windows\panther\unattend.xml'
              
              $xmldata = '<?xml version="1.0" encoding="utf-8"?>
              <unattend xmlns="urn:schemas-microsoft-com:unattend">
                <settings pass="auditSystem">
                  <component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <DriverPaths>
                      <PathAndCredentials wcm:keyValue="1" wcm:action="add">
                        <Path>c:\windows\LDDriverStore</Path>
                      </PathAndCredentials>
                    </DriverPaths>
                  </component>
                </settings>
                <settings pass="auditUser">
                  <component name="Microsoft-Windows-Deployment" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <RunSynchronous>
                      <RunSynchronousCommand wcm:action="add">
                        <Order>1</Order>
                        <Path>c:\windows\System32\sysprep\sysprep.exe /oobe /generalize /reboot </Path>
                      </RunSynchronousCommand>
                    </RunSynchronous>
                  </component>
                </settings>
                <settings pass="generalize">
                  <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
                  </component>
                </settings>
                <settings pass="oobeSystem">
                  <component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="AMD64">
                    <OOBE>
                      <HideEULAPage>true</HideEULAPage>
                      <ProtectYourPC>1</ProtectYourPC>
                      <SkipMachineOOBE>true</SkipMachineOOBE>
                      <SkipUserOOBE>true</SkipUserOOBE>
                    </OOBE>
                    <ProductKey>
                    </ProductKey>
                    <RegisteredOwner>
                    </RegisteredOwner>
                    <RegisteredOrganization>
                    </RegisteredOrganization>
                  </component>
                </settings>
                <settings pass="specialize">
                  <component name="Microsoft-Windows-Shell-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="AMD64">
                    <ComputerName>PCNAMEHERE</ComputerName>
                  </component>
                  <component name="Microsoft-Windows-UnattendedJoin" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="AMD64">
                    <Identification>
                      <Credentials>
                      </Credentials>
                      <MachineObjectOU></MachineObjectOU>
                      <JoinWorkgroup></JoinWorkgroup>
                    </Identification>
                  </component>
                </settings>
              </unattend>'
              
              $xml = [xml]($xmldata)
              $SN = gwmi win32_bios | Select –ExpandProperty SerialNumber
              $pcName = 'PC-'+$SN
              $xml.unattend.settings[4].component[0].ComputerName = $pcName
              $xml.Save($path)