Skip to content

SCCM OSD Computer Name Change

Featured Replies

Currently running SCCM 1511 with MDT 2013 integrated. We are looking to refresh all machines (desktops and laptops) from Win 7 to Win 10. My MDT Task Sequence works well, but I'm looking for a way to change the first 3 characters of the computer names. We have a standard naming convention, Example: current name looks like TW7NSDA-002-0000. The TW7 reflects Win 7. Is there a simple script I can implement in the Task Sequence to change TW7 to TW10 so the new computer name would reflect TW10NSDA-002-0000? Thanks!

  • Replies 21
  • Views 19.5k
  • Created
  • Last Reply

Top Posters In This Topic

Posted Images

This should work (I haven't tested it because im not at work atm)

$var = New-Object -ComObject Microsoft.SMS.TSEnvironment
$OSDComputerName = $var.Value("OSDComputerName")
$var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10")
  • 1 month later...
  • Author

Tregelen, did you ever get a chance to test it? I tested the script before adding it to my task sequence and it came back with errors.

How did you test it? It has to be run with the Task sequence environment (New-Object -ComObject Microsoft.SMS.TSEnvironment), so if all you did was run the VBS in windows that it wouldn't work.

It worked for me doing it during the task sequence. As YPCC said if you just run the script while in the OS then it wont work as the com object (Microsoft.SMS.TSEnvironment) wont be able to load. If you run it during the task sequence then it will work.

 

And make sure you running it as a PowerShell script during the task sequence.

  • Author

Thanks for your responses. My PowerShell skills are terrible at the moment, but I'm working on it...I'll give it a shot and follow up. Thanks again!

  • Author

Man, you guys are "da truth"!! Script worked like a charm! Many thanks! I'll definitely be keeping that one.

Happy to help

  • 3 weeks later...
  • Author

Tregelen,

 

If I wanted to add an additional line in the script to reflect laptops, could I just add the line at the end to look like this

 

  1. $var = New-Object -ComObject Microsoft.SMS.TSEnvironment
  2. $OSDComputerName = $var.Value("OSDComputerName")
  3. $var.Value("OSDComputerName") = ($OSDComputerName).Replace("TW7", "TW10")
  4. $var.Value("OSDComputerName") = ($OSDComputerName).Replace("LW7", "LW10")

Or would I need to add and elseif statement? I would think that it would ignore line 3, if nothing matches with what the script is looking for....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.