How do I change device name when applying an OS through SCCM? (automatically, without having to manually type in the device name when during boot)

Roland Diezmos 0 Reputation points
2023-07-27T01:52:06.5933333+00:00

For example: I want to change device name for 230 laptops and I want them to be using a format (ABA-Laptop-xx) and I need the number to increase every time when applying an OS to a new device. Can someone please assist me with this?

Example

ABA-Laptop-01

ABA-Laptop-02

ABA-Laptop-03 and so on.

Microsoft System Center
Microsoft System Center
A suite of Microsoft systems management products that offer solutions for managing datacenter resources, private clouds, and client devices.
1,074 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. XinGuo-MSFT 21,051 Reputation points
    2023-07-27T02:35:58.1933333+00:00

    Hi,

    To automatically change the device name when applying an OS through SCCM (System Center Configuration Manager) and have the number increase for each new device, you can use the following steps:

    Automate Computer Name during OSD in ConfigMgr 2012 with PowerShell

    Replace OSDComputerName.ps1

    # Define the base name and initial number
    $BaseName = "ABA-Laptop-"
    $InitialNumber = 1
    
    # Get the current number from a shared file to continue incrementing
    $NumberFilePath = "\\share\OSDeployment\DeviceNumber.txt"
    if (Test-Path -Path $NumberFilePath) {
        $CurrentNumber = Get-Content $NumberFilePath
    } else {
        $CurrentNumber = $InitialNumber
    }
    
    # Generate the new device name
    $NewDeviceName = $BaseName + "{0:D2}" -f $CurrentNumber
    
    # Increment the number for the next device
    $NextNumber = $CurrentNumber + 1
    
    # Save the next number to the shared file for future use
    $NextNumber | Out-File -FilePath $NumberFilePath
    
    
    $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $TSEnv.Value("OSDComputerName") = $NewDeviceName
    
    
    1 person found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.