none
Current Computer Name During OSD RRS feed

  • Question

  • I’m currently managing a System Center Configuration Manager (v1906) environment for a K-12 school district. We have One Primary site, 8 Distribution/PXE points (One per campus), and a SQL 2014 server.

    I currently fighting an issue with naming during the imaging process, specifically finding a way to display the current name of a machine while in pxe.

    The powers before me decided to use usernames in our naming convention so automatically naming a computer based on hardware or serial number is not an option. I have “OSDComputerNamePrompt.ps1” from “SCConfigMgr” in my task sequence right now which prompts my techs to enter a name at the beginning of the imaging process, it works well. However, it never fails while in a rush a tech will forget to obtain the current name of a computer before starting the process, and instead of booting back into windows and checking, they will just take a stab in the dark and guess what the name should be. Now my AD and SCCM are littered with remanences of failed name attempts or abandoned machines.

    My thought was to display the name in the OSDComputernamePrompt.ps dialog box using “$env:computername" but that produces a generic WINMICPC or MININT name. I’ve seen some scripts out there will query against SCCM and, if its known, will auto apply the previous name “else” prompt for a name, but I would rather it query and echo or produce that name for the tech, but still always prompt for name. I’m just not savvy enough to make those tweaks.

    The only place I can locally find any reference to the current computer name after pxe booting is if I use f8, mount the c: drive and browse to the NetSetup log file. There are several entries in this log that display the current name, but from here I’m still at a loss. Is there a way to take info out of that log and turn it into a variable that I can display in the computername.ps?

    Monday, December 9, 2019 10:34 PM

Answers

  • If it's a known computer (known to ConfigMgr), then the _SMSTSMachineName task sequence variable will contain the name of resource in ConfigMgr that corresponds to the system. In fact, if it's a known system, ConfigMgr will automatically reuse this name, however, if you still want to prompt, then use the value of this variable as the default.

    If it's an unknown system and you are PXE booting, there is no direct way to obtain the system's current name during WinPE.


    Jason | https://home.configmgrftw.com | @jasonsandys

    Tuesday, December 10, 2019 1:26 AM

All replies

  • If it's a known computer (known to ConfigMgr), then the _SMSTSMachineName task sequence variable will contain the name of resource in ConfigMgr that corresponds to the system. In fact, if it's a known system, ConfigMgr will automatically reuse this name, however, if you still want to prompt, then use the value of this variable as the default.

    If it's an unknown system and you are PXE booting, there is no direct way to obtain the system's current name during WinPE.


    Jason | https://home.configmgrftw.com | @jasonsandys

    Tuesday, December 10, 2019 1:26 AM
  • Okay I am reading up on using task sequences variables now and here is where I show my hand and reveal that I have been playing poker with Uno cards.

    This what I've put together after a brief search (rough draft but I'm not at work so I can't test right now):

    # Create TS Environment COM Object

    $TS = New-Object -ComObject Microsoft.SMS.TSEnvironment

    $Name=$TS.Value('_SMSTSMachineName')
    $Form = New-Object System.Windows.Forms.Form   
    $Form.Size = New-Object System.Drawing.Size(285,140) 
    $Form.MinimumSize = New-Object System.Drawing.Size(285,140)
    $Form.MaximumSize = New-Object System.Drawing.Size(285,140)
    $Form.StartPosition = "CenterScreen"
    $Form.SizeGripStyle = "Hide"
    $Form.Text = "$Name"
    $Form.ControlBox = $false
    $Form.TopMost = $true

    In theory "$Name" should represent the Computer Name according to SCCM and using "$Name" in the "$Form.Text ="" should produce said name in the dialog box title?

    Am in the ball park here or way off base? Because that seem way to simple for a problem I've been mulling over for a while now... I missing something right?

    I kind of figured Unknown (to SCCM) would be a lost cause. In our environment 99 percent of unknowns are new machines which go through me before being put into production.
    I'm almost always pretty thorough... mostly.

    Once in production though, our computers and laptops get shuffled around, lost, and reassigned without our departments consent or knowledge. When using user names and campus locations as a naming scheme keeping track of these at a quick glance becomes a lost cause. That's why I cant really trust SCCM to reuse the current name, its not uncommon to trouble shoot a machine for a user at the Middle School only to find out the current name is assigned to a user at the High School. If my techs can catch that before the point of no return then hopefully they will either cancel the deployment and correct the name the proper way, or at least call me and let me delete the object from ad/sccm before it becomes a duplicate or abandoned object. 

    Tuesday, December 10, 2019 4:03 AM
  • Hi,

    Based as my test, SMSTSMachineName task sequence variable name stores and specifies the computer name. Stores the name of the computer that the task sequence uses to log all status messages. To change the computer name in the new OS, use the OSDComputerName variable.

    https://docs.microsoft.com/en-us/configmgr/osd/understand/task-sequence-variables


    For unknown computer, the name will generate randomly and store in the SMSTSMachineName. You can check it during OSD deployment via the following command:
    $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $tsenv.value("osdcomputername"),$tsenv.value("_smstsmachinename"))

      

    When apply OS if no OSDComputerName is existing, it will use the name under SMSTSMachineName in unattand file.

    For known computer, it will use the former name if no OSDComputerName is granted.
     
    So If you want to display the name, you can get it from the SMSTSMachineName value.
     
    Hope it can help.
     
    Best regards.
    Crystal

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, December 10, 2019 7:50 AM
  • >In theory "$Name" should represent the Computer Name according to SCCM and using "$Name" in the "$Form.Text ="" should produce said name in the dialog box title?

    Correct.


    Jason | https://home.configmgrftw.com | @jasonsandys

    Tuesday, December 10, 2019 3:08 PM
  • Thanks both of you, It really was this simple. I tested the commands today and sure enough I can produce the actual computer name. One day I will tell my grand kids about you all. 
    Tuesday, December 10, 2019 8:48 PM
  • Hi,
     
    Thanks for your feedback. I am glad the information in our forum can help. If there's anything else we can help in the future, feel free to post in our forum.
     
    Thanks and have a nice day!
     
    Best regards.
    Crystal


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, December 11, 2019 1:23 AM