Automatic PC naming during task sequence

Brett Dalton 21 Reputation points
2020-11-02T05:14:55.877+00:00

I am setting up an Endpoint Configuration Manager distribution point on my supplier's infrastructure so they can build PC's for us before they are shipped to site. All PC's need to be named automatically based on certain criteria during the task sequence. The idea is to have the entire process as automated and hands-off as possible.

Naming convention rules:

  1. 3 letter prefix common to ALL PC's (does not change regardless of build site)
  2. 5 digit sequential number within a certain range based on the site where the machines are built (i.e. computers built at the supplier will be named within the 60001 to 99999 range)

The biggest challenge I think I'm facing here is making sure I don't end up with duplicate names as a number of machines could be getting built simultaneously. I'd also like the hostname to be displayed on-screen during the built so techs can put the correct asset label on the PC. I would really like it if the PC label got printed automatically at the same time that the PC name was assigned but that might be something for the magic fairy dust.

Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
907 questions
0 comments No comments
{count} votes

Accepted answer
  1. Fiona Yan-MSFT 2,311 Reputation points
    2020-11-09T06:42:04.66+00:00

    @Brett Dalton

    --->Yes,we could set up a read only DC on our DP to reduce the query time.

    --->As we mentioned we also could use CSV file to import multiple computers in our SCCM.
    Here is a similar situation we may want to see it:
    how-can-i-import-computers-into-sccm-2012-using-a-file
    Note: this is non-official article just for your reference.

    --->There are could be same name when we query at the same time so we need to add one lock variable to limit the action to wait for the previous action.The main logical may like this:
    1.We need to prepare one txt file we prepare previously:
    The content may like this:
    "Locked = False ,Sequence Number = 0002"

    2.We open our script to read this txt file every time and plus the computer name,the structure may like this,we could add more details on our own:
    We define the status as two types:false(continue) and true(wait for 5 sec).
    ===start->read from txt file->if locked=false->{ get computer name,query AD, confirm, pass variable to TS}->Sequence Number ++1 and then save to file.
    ===start->read from txt file->if Locked = True then save file and ->{sleep 5 seconds go to start}

    Have a nice day!


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Gary Blok 1,736 Reputation points
    2020-11-09T07:02:16.333+00:00

    For creating the objects in CM before starting OSD, this script would have some examples for you. It's how I create VMs, but check CM first to make sure the name it available before creating it and starting OSD.

    https://docs.recastsoftware.com/ConfigMgr-Docs/Hyper-V-Automate-OSD-Test-Machines.html

    Should be able to get some ideas from that. I'm a huge fan of only imaging known computers. If you can get the MAC Address for the machines ahead of time, you can onboard them and pre-provision everything the machines would need.

    1 person found this answer helpful.
    0 comments No comments

  2. Fiona Yan-MSFT 2,311 Reputation points
    2020-11-02T07:50:21.91+00:00

    @Brett Dalton

    Thank you for posting in Microsoft Q&A forum.

    We should be able to set available environment variables from the Power shell script, and then set the OSD Computer Name TS variable as an environment variable in the subsequent steps, and our desired target may need to add some lines to the rule so that we could verify whether the device name exists, if our device name exists in our AD, and our script also could continue to add the name plus until the computer name is the new name of our AD, just do it before applying the Windows settings.
    There are many guides available for us to choose the computer name .It could be serial number or prompt for host name or any format that we would like to have. Here is an article for us to refer to:
    https://msendpointmgr.com/2013/06/03/automate-computer-name-during-osd-in-configmgr-2012-with-powershell/
    Note: This is non-official Microsoft article just for your reference.

    Have a nice day!


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Brett Dalton 21 Reputation points
    2020-11-11T23:01:00.863+00:00

    Apologies for the lack of response, things have been a bit hectic.

    At the moment I'm thinking about a separate computer (just a low-end mini desktop would do) that has a CSV file I can update using scheduled tasks each morning at say 5am that contains the next available 100 or so names. The TS, which has been customised for and deployed to only this distribution point, will reference this CSV file for the name. Still working on where in the TS I'm going to do this, whether it's right at the start when it sets the name or just as a change computer name PS script later on but I can do any testing on the DP I have in my office as it's a similar configuration to what I'll have at the warehouse. The label printer is also connected to this box and I'll need to create a trigger that prints the label when the file is queried for the next available name.